Skip to content

Commit 230bad7

Browse files
committed
Merge branch 'optimize-3' of https://github.com/LamentXU123/php-src into optimize-3
2 parents ba2a1f5 + b8b4a7c commit 230bad7

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

ext/uri/uri_parser_rfc3986.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -369,24 +369,19 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_path_read(void
369369

370370
zend_string *str = zend_string_alloc(total_len, false);
371371
char *out = ZSTR_VAL(str);
372-
size_t pos = 0;
373372

374373
if (need_leading_slash) {
375-
out[pos++] = '/';
374+
*(out++) = '/';
376375
}
377376

378377
for (const UriPathSegmentA *p = uriparser_uri->pathHead; p; p = p->next) {
379-
const size_t len = get_text_range_length(&p->text);
380-
if (len > 0) {
381-
memcpy(out + pos, p->text.first, len);
382-
pos += len;
383-
}
378+
out = zend_mempcpy(out, p->text.first, get_text_range_length(&p->text));
384379
if (p->next) {
385-
out[pos++] = '/';
380+
*(out++) = '/';
386381
}
387382
}
388383

389-
out[total_len] = '\0';
384+
*out = '\0';
390385
ZVAL_STR(retval, str);
391386
} else if (uriparser_uri->absolutePath) {
392387
ZVAL_CHAR(retval, '/');

0 commit comments

Comments
 (0)