1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Add a 1-char fastpath to implode() (#19276)

This commit is contained in:
Alexandre Daubois
2025-09-10 16:52:31 +02:00
committed by GitHub
parent 22d002e068
commit 29c7ee4cd4

View File

@@ -1026,7 +1026,11 @@ PHPAPI void php_implode(const zend_string *glue, HashTable *pieces, zval *return
}
cptr -= ZSTR_LEN(glue);
memcpy(cptr, ZSTR_VAL(glue), ZSTR_LEN(glue));
if (ZSTR_LEN(glue) == 1) {
*cptr = ZSTR_VAL(glue)[0];
} else {
memcpy(cptr, ZSTR_VAL(glue), ZSTR_LEN(glue));
}
}
free_alloca(strings, use_heap);