Skip to content

Instantly share code, notes, and snippets.

@lpe234
Last active December 28, 2018 09:19
Show Gist options
  • Save lpe234/cf60fd18191a396257f92b7d52e1613b to your computer and use it in GitHub Desktop.
Save lpe234/cf60fd18191a396257f92b7d52e1613b to your computer and use it in GitHub Desktop.
redis-core
// 💕核心科技~
dictEntry *dictFind(dict *d, const void *key)
{
dictEntry *he;
unsigned int h, idx, table;
if (d->ht[0].size == 0) return NULL; /* We don't have a table at all */
if (dictIsRehashing(d)) _dictRehashStep(d);
h = dictHashKey(d, key);
for (table = 0; table <= 1; table++) {
idx = h & d->ht[table].sizemask;
he = d->ht[table].table[idx];
while(he) {
if (dictCompareKeys(d, key, he->key))
return he;
he = he->next;
}
if (!dictIsRehashing(d)) return NULL;
}
return NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment