summaryrefslogtreecommitdiff
path: root/src/dict.c
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2021-05-09 20:21:18 +0800
committerGitHub <noreply@github.com>2021-05-09 15:21:18 +0300
commit56976ffb4940b95cc3746b115d7f957c9e4b20f8 (patch)
tree5fe6e16f674374c32539f8a1961988433a0bb00d /src/dict.c
parent57b94eacaa64591295c9f9f9bb50eed9ed8b9a54 (diff)
downloadredis-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/dict.c')
-rw-r--r--src/dict.c9
1 files changed, 4 insertions, 5 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;