- h1 = h & d->ht[0].sizemask;
- h2 = h & d->ht[1].sizemask;
- /* Search if this slot does not already contain the given key */
- he = d->ht[0].table[h1];
- while(he) {
- if (dictCompareHashKeys(d, key, he->key))
- return -1;
- he = he->next;
- }
- if (!dictIsRehashing(d)) return h1;
- /* Check the second hash table */
- he = d->ht[1].table[h2];
- while(he) {
- if (dictCompareHashKeys(d, key, he->key))
- return -1;
- he = he->next;
+ for (table = 0; table <= 1; table++) {
+ idx = h & d->ht[table].sizemask;
+ /* Search if this slot does not already contain the given key */
+ he = d->ht[table].table[idx];
+ while(he) {
+ if (dictCompareHashKeys(d, key, he->key))
+ return -1;
+ he = he->next;
+ }
+ if (!dictIsRehashing(d)) break;