Skip to content

Commit 1b169bf

Browse files
committed
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.
1 parent 4762d46 commit 1b169bf

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

ext/standard/array.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7023,6 +7023,7 @@ PHP_FUNCTION(array_chunk)
70237023
}
70247024

70257025
array_init_size(return_value, (uint32_t)(((num_in - 1) / size) + 1));
7026+
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
70267027

70277028
ZVAL_UNDEF(&chunk);
70287029

0 commit comments

Comments
 (0)