Avoid second RHASH_AR_TABLE_REF lookup

This commit is contained in:
Erik Berlin 2025-07-03 21:23:51 -04:00 committed by John Hawthorn
parent 900eb04853
commit abc8745fc3

5
hash.c
View file

@ -882,8 +882,9 @@ ar_general_foreach(VALUE hash, st_foreach_check_callback_func *func, st_update_c
if (replace) {
(*replace)(&key, &val, arg, TRUE);
// TODO: pair should be same as pair before.
pair = RHASH_AR_TABLE_REF(hash, i);
// Pair should not have moved
HASH_ASSERT(pair == RHASH_AR_TABLE_REF(hash, i));
pair->key = (VALUE)key;
pair->val = (VALUE)val;
}