Skip to content

Commit 8645657

Browse files
committed
Fix performance degradation introduced in c2547ab
After discussing with someone, our current running theory is that the local variable forces the compiler to reserve an additional register for the whole lifespan of the function. Dropping it and just loading the value should restore the previous code generation. Closes GH-9876
1 parent 6e87485 commit 8645657

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Zend/zend_hash.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,15 +658,14 @@ ZEND_API void ZEND_FASTCALL zend_hash_iterators_advance(HashTable *ht, HashPosit
658658
/* Hash must be known and precomputed before */
659659
static zend_always_inline Bucket *zend_hash_find_bucket(const HashTable *ht, const zend_string *key)
660660
{
661-
zend_ulong key_hash = ZSTR_H(key);
662661
uint32_t nIndex;
663662
uint32_t idx;
664663
Bucket *p, *arData;
665664

666-
ZEND_ASSERT(key_hash != 0 && "Hash must be known");
665+
ZEND_ASSERT(ZSTR_H(key) != 0 && "Hash must be known");
667666

668667
arData = ht->arData;
669-
nIndex = key_hash | ht->nTableMask;
668+
nIndex = ZSTR_H(key) | ht->nTableMask;
670669
idx = HT_HASH_EX(arData, nIndex);
671670

672671
if (UNEXPECTED(idx == HT_INVALID_IDX)) {
@@ -678,7 +677,7 @@ static zend_always_inline Bucket *zend_hash_find_bucket(const HashTable *ht, con
678677
}
679678

680679
while (1) {
681-
if (p->h == key_hash &&
680+
if (p->h == ZSTR_H(key) &&
682681
EXPECTED(p->key) &&
683682
zend_string_equal_content(p->key, key)) {
684683
return p;

0 commit comments

Comments
 (0)