Skip to content

Commit ea387fc

Browse files
authored
Avoid useless initializations of fci/fcc in array functions (#18273)
These cause cache misses due to global access, in phpstan (notably the array_map). Initializing these isn't necessary because ZPP initializes it for us. Only for optional arguments do we need to be careful; for `array_filter` we still reset the `fci` but not `fci_cache` because `fci` is not necessarily set by ZPP but is conditionally used to access `fci_cache`.
1 parent 93a3256 commit ea387fc

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: ext/standard/array.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -6439,7 +6439,7 @@ PHP_FUNCTION(array_reduce)
64396439
zval args[2];
64406440
zval *operand;
64416441
zend_fcall_info fci;
6442-
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
6442+
zend_fcall_info_cache fci_cache;
64436443
zval *initial = NULL;
64446444
HashTable *htbl;
64456445

@@ -6515,7 +6515,7 @@ PHP_FUNCTION(array_filter)
65156515
zend_long use_type = 0;
65166516
zend_string *string_key;
65176517
zend_fcall_info fci = empty_fcall_info;
6518-
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
6518+
zend_fcall_info_cache fci_cache;
65196519
zend_ulong num_key;
65206520

65216521
ZEND_PARSE_PARAMETERS_START(1, 3)
@@ -6649,7 +6649,7 @@ PHP_FUNCTION(array_find)
66496649
{
66506650
HashTable *array;
66516651
zend_fcall_info fci;
6652-
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
6652+
zend_fcall_info_cache fci_cache;
66536653

66546654
ZEND_PARSE_PARAMETERS_START(2, 2)
66556655
Z_PARAM_ARRAY_HT(array)
@@ -6665,7 +6665,7 @@ PHP_FUNCTION(array_find_key)
66656665
{
66666666
HashTable *array;
66676667
zend_fcall_info fci;
6668-
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
6668+
zend_fcall_info_cache fci_cache;
66696669

66706670
ZEND_PARSE_PARAMETERS_START(2, 2)
66716671
Z_PARAM_ARRAY_HT(array)
@@ -6681,7 +6681,7 @@ PHP_FUNCTION(array_any)
66816681
{
66826682
HashTable *array;
66836683
zend_fcall_info fci;
6684-
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
6684+
zend_fcall_info_cache fci_cache;
66856685

66866686
ZEND_PARSE_PARAMETERS_START(2, 2)
66876687
Z_PARAM_ARRAY_HT(array)
@@ -6697,7 +6697,7 @@ PHP_FUNCTION(array_all)
66976697
{
66986698
HashTable *array;
66996699
zend_fcall_info fci;
6700-
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
6700+
zend_fcall_info_cache fci_cache;
67016701

67026702
ZEND_PARSE_PARAMETERS_START(2, 2)
67036703
Z_PARAM_ARRAY_HT(array)
@@ -6714,8 +6714,8 @@ PHP_FUNCTION(array_map)
67146714
zval *arrays = NULL;
67156715
int n_arrays = 0;
67166716
zval result;
6717-
zend_fcall_info fci = empty_fcall_info;
6718-
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
6717+
zend_fcall_info fci;
6718+
zend_fcall_info_cache fci_cache;
67196719
int i;
67206720
uint32_t k, maxlen = 0;
67216721

0 commit comments

Comments
 (0)