mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
dict.c minor optimization
This commit is contained in:
parent
7b52ef1da2
commit
6ed8c28230
@ -424,7 +424,7 @@ static int dictGenericDelete(dict *d, const void *key, int nofree)
|
||||
he = d->ht[table].table[idx];
|
||||
prevHe = NULL;
|
||||
while(he) {
|
||||
if (dictCompareKeys(d, key, he->key)) {
|
||||
if (key==he->key || dictCompareKeys(d, key, he->key)) {
|
||||
/* Unlink the element from the list */
|
||||
if (prevHe)
|
||||
prevHe->next = he->next;
|
||||
@ -494,14 +494,14 @@ 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 (d->ht[0].used + d->ht[1].used == 0) return NULL; /* dict is empty */
|
||||
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))
|
||||
if (key==he->key || dictCompareKeys(d, key, he->key))
|
||||
return he;
|
||||
he = he->next;
|
||||
}
|
||||
@ -981,7 +981,7 @@ static int _dictKeyIndex(dict *d, const void *key)
|
||||
/* Search if this slot does not already contain the given key */
|
||||
he = d->ht[table].table[idx];
|
||||
while(he) {
|
||||
if (dictCompareKeys(d, key, he->key))
|
||||
if (key==he->key || dictCompareKeys(d, key, he->key))
|
||||
return -1;
|
||||
he = he->next;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user