@@ -655,21 +655,18 @@ ZEND_API void ZEND_FASTCALL zend_hash_iterators_advance(HashTable *ht, HashPosit
655655 }
656656}
657657
658- static zend_always_inline Bucket * zend_hash_find_bucket (const HashTable * ht , zend_string * key , bool known_hash )
658+ /* Hash must be known and precomputed before */
659+ static zend_always_inline Bucket * zend_hash_find_bucket (const HashTable * ht , const zend_string * key )
659660{
660- zend_ulong h ;
661+ zend_ulong key_hash = ZSTR_H ( key ) ;
661662 uint32_t nIndex ;
662663 uint32_t idx ;
663664 Bucket * p , * arData ;
664665
665- if (known_hash ) {
666- h = ZSTR_H (key );
667- ZEND_ASSERT (h != 0 && "Hash must be known" );
668- } else {
669- h = zend_string_hash_val (key );
670- }
666+ ZEND_ASSERT (key_hash != 0 && "Hash must be known" );
667+
671668 arData = ht -> arData ;
672- nIndex = h | ht -> nTableMask ;
669+ nIndex = key_hash | ht -> nTableMask ;
673670 idx = HT_HASH_EX (arData , nIndex );
674671
675672 if (UNEXPECTED (idx == HT_INVALID_IDX )) {
@@ -681,7 +678,7 @@ static zend_always_inline Bucket *zend_hash_find_bucket(const HashTable *ht, zen
681678 }
682679
683680 while (1 ) {
684- if (p -> h == ZSTR_H ( key ) &&
681+ if (p -> h == key_hash &&
685682 EXPECTED (p -> key ) &&
686683 zend_string_equal_content (p -> key , key )) {
687684 return p ;
@@ -758,7 +755,7 @@ static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_s
758755 zend_hash_packed_to_hash (ht );
759756 }
760757 } else if ((flag & HASH_ADD_NEW ) == 0 || ZEND_DEBUG ) {
761- p = zend_hash_find_bucket (ht , key , 1 );
758+ p = zend_hash_find_bucket (ht , key );
762759
763760 if (p ) {
764761 zval * data ;
@@ -1166,7 +1163,8 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_set_bucket_key(HashTable *ht, Bucket *b,
11661163 HT_ASSERT_RC1 (ht );
11671164 ZEND_ASSERT (!HT_IS_PACKED (ht ));
11681165
1169- p = zend_hash_find_bucket (ht , key , 0 );
1166+ (void )zend_string_hash_val (key );
1167+ p = zend_hash_find_bucket (ht , key );
11701168 if (UNEXPECTED (p )) {
11711169 return (p == b ) ? & p -> val : NULL ;
11721170 }
@@ -2526,17 +2524,18 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *ke
25262524
25272525 IS_CONSISTENT (ht );
25282526
2529- p = zend_hash_find_bucket (ht , key , 0 );
2527+ (void )zend_string_hash_val (key );
2528+ p = zend_hash_find_bucket (ht , key );
25302529 return p ? & p -> val : NULL ;
25312530}
25322531
2533- ZEND_API zval * ZEND_FASTCALL zend_hash_find_known_hash (const HashTable * ht , zend_string * key )
2532+ ZEND_API zval * ZEND_FASTCALL zend_hash_find_known_hash (const HashTable * ht , const zend_string * key )
25342533{
25352534 Bucket * p ;
25362535
25372536 IS_CONSISTENT (ht );
25382537
2539- p = zend_hash_find_bucket (ht , key , 1 );
2538+ p = zend_hash_find_bucket (ht , key );
25402539 return p ? & p -> val : NULL ;
25412540}
25422541
0 commit comments