diff options
author | Binbin <binloveplay1314@qq.com> | 2021-05-09 20:21:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-09 15:21:18 +0300 |
commit | 56976ffb4940b95cc3746b115d7f957c9e4b20f8 (patch) | |
tree | 5fe6e16f674374c32539f8a1961988433a0bb00d /src | |
parent | 57b94eacaa64591295c9f9f9bb50eed9ed8b9a54 (diff) | |
download | redis-56976ffb4940b95cc3746b115d7f957c9e4b20f8.tar.gz |
Use function instead of code in dict.c and delete dead code in dict.h (#8878)
Use function instead of code in dict.c and delete dead code in dict.h
Diffstat (limited to 'src')
-rw-r--r-- | src/dict.c | 9 | ||||
-rw-r--r-- | src/dict.h | 5 |
2 files changed, 4 insertions, 10 deletions
diff --git a/src/dict.c b/src/dict.c index 21c616e6f..f10d0ca36 100644 --- a/src/dict.c +++ b/src/dict.c @@ -381,7 +381,7 @@ dictEntry *dictAddOrFind(dict *d, void *key) { return entry ? entry : existing; } -/* Search and remove an element. This is an helper function for +/* Search and remove an element. This is a helper function for * dictDelete() and dictUnlink(), please check the top comment * of those functions. */ static dictEntry *dictGenericDelete(dict *d, const void *key, int nofree) { @@ -389,7 +389,8 @@ static dictEntry *dictGenericDelete(dict *d, const void *key, int nofree) { dictEntry *he, *prevHe; int table; - if (d->ht[0].used == 0 && d->ht[1].used == 0) return NULL; + /* dict is empty */ + if (dictSize(d) == 0) return NULL; if (dictIsRehashing(d)) _dictRehashStep(d); h = dictHashKey(d, key); @@ -406,9 +407,7 @@ static dictEntry *dictGenericDelete(dict *d, const void *key, int nofree) { else d->ht[table].table[idx] = he->next; if (!nofree) { - dictFreeKey(d, he); - dictFreeVal(d, he); - zfree(he); + dictFreeUnlinkedEntry(d, he); } d->ht[table].used--; return he; diff --git a/src/dict.h b/src/dict.h index 7e2258960..02af65cf8 100644 --- a/src/dict.h +++ b/src/dict.h @@ -196,11 +196,6 @@ unsigned long dictScan(dict *d, unsigned long v, dictScanFunction *fn, dictScanB uint64_t dictGetHash(dict *d, const void *key); dictEntry **dictFindEntryRefByPtrAndHash(dict *d, const void *oldptr, uint64_t hash); -/* Hash table types */ -extern dictType dictTypeHeapStringCopyKey; -extern dictType dictTypeHeapStrings; -extern dictType dictTypeHeapStringCopyKeyValue; - #ifdef REDIS_TEST int dictTest(int argc, char *argv[], int accurate); #endif |