"vscode:/vscode.git/clone" did not exist on "49f7d173b432408c55b40bc529556c9aeff8fc53"
Unverified Commit 56976ffb authored by Binbin's avatar Binbin Committed by GitHub
Browse files

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
parent 57b94eac
...@@ -381,7 +381,7 @@ dictEntry *dictAddOrFind(dict *d, void *key) { ...@@ -381,7 +381,7 @@ dictEntry *dictAddOrFind(dict *d, void *key) {
return entry ? entry : existing; 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 * dictDelete() and dictUnlink(), please check the top comment
* of those functions. */ * of those functions. */
static dictEntry *dictGenericDelete(dict *d, const void *key, int nofree) { static dictEntry *dictGenericDelete(dict *d, const void *key, int nofree) {
...@@ -389,7 +389,8 @@ 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; dictEntry *he, *prevHe;
int table; 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); if (dictIsRehashing(d)) _dictRehashStep(d);
h = dictHashKey(d, key); h = dictHashKey(d, key);
...@@ -406,9 +407,7 @@ static dictEntry *dictGenericDelete(dict *d, const void *key, int nofree) { ...@@ -406,9 +407,7 @@ static dictEntry *dictGenericDelete(dict *d, const void *key, int nofree) {
else else
d->ht[table].table[idx] = he->next; d->ht[table].table[idx] = he->next;
if (!nofree) { if (!nofree) {
dictFreeKey(d, he); dictFreeUnlinkedEntry(d, he);
dictFreeVal(d, he);
zfree(he);
} }
d->ht[table].used--; d->ht[table].used--;
return he; return he;
......
...@@ -196,11 +196,6 @@ unsigned long dictScan(dict *d, unsigned long v, dictScanFunction *fn, dictScanB ...@@ -196,11 +196,6 @@ unsigned long dictScan(dict *d, unsigned long v, dictScanFunction *fn, dictScanB
uint64_t dictGetHash(dict *d, const void *key); uint64_t dictGetHash(dict *d, const void *key);
dictEntry **dictFindEntryRefByPtrAndHash(dict *d, const void *oldptr, uint64_t hash); 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 #ifdef REDIS_TEST
int dictTest(int argc, char *argv[], int accurate); int dictTest(int argc, char *argv[], int accurate);
#endif #endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment