[php-src] master: ext/standard: Use ZVAL_STRINGL_FAST() in php_explode_negative_limit() (#23631)
| From: | Weilin Du via GitHub | Date: | Thu, 10 Sep 2026 16:03:59 +0000 |
| Subject: | [php-src] master: ext/standard: Use ZVAL_STRINGL_FAST() in php_explode_negative_limit() (#23631) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141163@lists.php.net to get a copy of this message | ||
Author: Weilin Du (LamentXU123)
Committer: GitHub (web-flow)
Pusher: LamentXU123
Date: 2026-09-11T00:03:56+08:00
Commit: https://github.com/php/php-src/commit/ac53f14223b4cda3199675878113f82de4d1717a
Raw diff: https://github.com/php/php-src/commit/ac53f14223b4cda3199675878113f82de4d1717a.diff
ext/standard: Use ZVAL_STRINGL_FAST() in php_explode_negative_limit() (#23631)
Ideally this save a emalloc + memcpy + free.
Changed paths:
M ext/standard/string.c
Diff:
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 2d868513e4ad..04c3c21b2866 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -921,7 +921,7 @@ PHPAPI void php_explode_negative_limit(const zend_string *delim, zend_string *st
to_return = limit + found;
/* limit is at least -1 therefore no need of bounds checking : i will be always less than found
*/
for (i = 0; i < to_return; i++) { /* this checks also for to_return > 0 */
- ZVAL_STRINGL(&tmp, positions[i], (positions[i+1] - ZSTR_LEN(delim)) - positions[i]);
+ ZVAL_STRINGL_FAST(&tmp, positions[i], (positions[i+1] - ZSTR_LEN(delim)) - positions[i]);
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
}
efree((void *)positions);