Skip to content

Commit ba2a1f5

Browse files
committed
use pointer arithmetic
1 parent 992e5a7 commit ba2a1f5

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

ext/uri/uri_parser_rfc3986.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,12 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_host_read(void
240240
const size_t host_len = get_text_range_length(&uriparser_uri->hostText);
241241
zend_string *host_str = zend_string_alloc(host_len + 2, false);
242242

243-
ZSTR_VAL(host_str)[0] = '[';
244-
memcpy(ZSTR_VAL(host_str) + 1, uriparser_uri->hostText.first, host_len);
245-
ZSTR_VAL(host_str)[host_len + 1] = ']';
246-
ZSTR_VAL(host_str)[host_len + 2] = '\0';
243+
char *out = ZSTR_VAL(host_str);
244+
245+
*(out++) = '[';
246+
out = zend_mempcpy(out, uriparser_uri->hostText.first, host_len);
247+
*(out++) = ']';
248+
*out = '\0';
247249

248250
ZVAL_STR(retval, host_str);
249251
} else {

0 commit comments

Comments
 (0)