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

Allocate array eagerly in array_chunk

By preallocating it as a packed array, we save the initial
initialization overhead.
Gives a few extra percentage points improvement.
This commit is contained in:
Niels Dossche
2025-07-20 16:26:42 +02:00
parent 4762d46427
commit 1b169bf28e

View File

@@ -7023,6 +7023,7 @@ PHP_FUNCTION(array_chunk)
}
array_init_size(return_value, (uint32_t)(((num_in - 1) / size) + 1));
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
ZVAL_UNDEF(&chunk);