Skip to content

Commit 008446f

Browse files
committed
Use consumed_args for array_reduce and callback hot paths
1 parent 7b302fc commit 008446f

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

Zend/zend_API.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ typedef struct _zend_fcall_info_cache {
340340

341341
#define ZEND_FCI_INITIALIZED(fci) ((fci).size != 0)
342342
#define ZEND_FCC_INITIALIZED(fcc) ((fcc).function_handler != NULL)
343+
#define ZEND_FCI_CONSUMED_ARG(arg_num) (1u << ((arg_num) - 1))
343344

344345
ZEND_API int zend_next_free_module(void);
345346

ext/pcre/php_pcre.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,7 @@ static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cach
15701570
fci->retval = &retval;
15711571
fci->param_count = 1;
15721572
fci->params = &arg;
1573+
fci->consumed_args = ZEND_FCI_CONSUMED_ARG(1);
15731574
zend_call_function(fci, fcc);
15741575
zval_ptr_dtor(&arg);
15751576
if (EXPECTED(Z_TYPE(retval) == IS_STRING)) {

ext/standard/array.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,7 @@ static zend_result php_array_walk(
13861386
fci.retval = &retval;
13871387
fci.param_count = userdata ? 3 : 2;
13881388
fci.params = args;
1389+
fci.consumed_args = ZEND_FCI_CONSUMED_ARG(2);
13891390

13901391
zend_hash_internal_pointer_reset_ex(target_hash, &pos);
13911392
ht_iter = zend_hash_iterator_add(target_hash, pos);
@@ -6409,6 +6410,7 @@ PHP_FUNCTION(array_reduce)
64096410
fci.retval = return_value;
64106411
fci.param_count = 2;
64116412
fci.params = args;
6413+
fci.consumed_args = ZEND_FCI_CONSUMED_ARG(1);
64126414

64136415
ZEND_HASH_FOREACH_VAL(htbl, operand) {
64146416
ZVAL_COPY_VALUE(&args[0], return_value);

main/output.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,7 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl
972972
handler->func.user->fci.param_count = 2;
973973
handler->func.user->fci.params = ob_args;
974974
handler->func.user->fci.retval = &retval;
975+
handler->func.user->fci.consumed_args = ZEND_FCI_CONSUMED_ARG(1);
975976

976977
if (SUCCESS == zend_call_function(&handler->func.user->fci, &handler->func.user->fcc) && Z_TYPE(retval) != IS_UNDEF) {
977978
if (handler->flags & PHP_OUTPUT_HANDLER_PRODUCED_OUTPUT) {

0 commit comments

Comments
 (0)