@@ -2004,6 +2004,34 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_new_element_for_s
2004
2004
zend_throw_error (NULL , "[] operator not supported for strings" );
2005
2005
}
2006
2006
2007
+ static zend_never_inline zend_uchar slow_index_convert (const zval * dim , zend_value * value )
2008
+ {
2009
+ switch (Z_TYPE_P (dim )) {
2010
+ case IS_UNDEF :
2011
+ ZVAL_UNDEFINED_OP2 ();
2012
+ /* break missing intentionally */
2013
+ case IS_NULL :
2014
+ value -> str = ZSTR_EMPTY_ALLOC ();
2015
+ return IS_STRING ;
2016
+ case IS_DOUBLE :
2017
+ value -> lval = zend_dval_to_lval (Z_DVAL_P (dim ));
2018
+ return IS_LONG ;
2019
+ case IS_RESOURCE :
2020
+ zend_use_resource_as_offset (dim );
2021
+ value -> lval = Z_RES_HANDLE_P (dim );
2022
+ return IS_LONG ;
2023
+ case IS_FALSE :
2024
+ value -> lval = 0 ;
2025
+ return IS_LONG ;
2026
+ case IS_TRUE :
2027
+ value -> lval = 1 ;
2028
+ return IS_LONG ;
2029
+ default :
2030
+ zend_illegal_offset ();
2031
+ return IS_NULL ;
2032
+ }
2033
+ }
2034
+
2007
2035
static zend_always_inline zval * zend_fetch_dimension_address_inner (HashTable * ht , const zval * dim , int dim_type , int type EXECUTE_DATA_DC )
2008
2036
{
2009
2037
zval * retval = NULL ;
@@ -2082,33 +2110,21 @@ static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht
2082
2110
break ;
2083
2111
}
2084
2112
}
2113
+ } else if (EXPECTED (Z_TYPE_P (dim ) == IS_REFERENCE )) {
2114
+ dim = Z_REFVAL_P (dim );
2115
+ goto try_again ;
2085
2116
} else {
2086
- switch (Z_TYPE_P (dim )) {
2087
- case IS_UNDEF :
2088
- ZVAL_UNDEFINED_OP2 ();
2089
- /* break missing intentionally */
2090
- case IS_NULL :
2091
- offset_key = ZSTR_EMPTY_ALLOC ();
2092
- goto str_index ;
2093
- case IS_DOUBLE :
2094
- hval = zend_dval_to_lval (Z_DVAL_P (dim ));
2095
- goto num_index ;
2096
- case IS_RESOURCE :
2097
- zend_use_resource_as_offset (dim );
2098
- hval = Z_RES_HANDLE_P (dim );
2099
- goto num_index ;
2100
- case IS_FALSE :
2101
- hval = 0 ;
2102
- goto num_index ;
2103
- case IS_TRUE :
2104
- hval = 1 ;
2105
- goto num_index ;
2106
- case IS_REFERENCE :
2107
- dim = Z_REFVAL_P (dim );
2108
- goto try_again ;
2109
- default :
2110
- zend_illegal_offset ();
2111
- retval = (type == BP_VAR_W || type == BP_VAR_RW ) ?
2117
+ zend_value val ;
2118
+ zend_uchar t = slow_index_convert (dim , & val );
2119
+
2120
+ if (t == IS_STRING ) {
2121
+ offset_key = val .str ;
2122
+ goto str_index ;
2123
+ } else if (t == IS_LONG ) {
2124
+ hval = val .lval ;
2125
+ goto num_index ;
2126
+ } else {
2127
+ retval = (type == BP_VAR_W || type == BP_VAR_RW ) ?
2112
2128
NULL : & EG (uninitialized_zval );
2113
2129
}
2114
2130
}
0 commit comments