diff options
author | oranagra <oran@redislabs.com> | 2016-05-09 18:01:09 +0300 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2016-09-14 12:18:59 +0200 |
commit | afcbcc0e58749ebbebcd595c120d17a0e3dbb82e (patch) | |
tree | 9f4ba46910e78486ee1f23a0578aafdd6b4a701e /src/dict.h | |
parent | 8c84c962cfb6359401c2df92f79d7e848a34802f (diff) | |
download | redis-afcbcc0e58749ebbebcd595c120d17a0e3dbb82e.tar.gz |
dict.c: introduce dictUnlink().
Notes by @antirez:
This patch was picked from a larger commit by Oran and adapted to change
the API a bit. The basic idea is to avoid double lookups when there is
to use the value of the deleted entry.
BEFORE:
entry = dictFind( ... ); /* 1st lookup. */
/* Do somethjing with the entry. */
dictDelete(...); /* 2nd lookup. */
AFTER:
entry = dictUnlink( ... ); /* 1st lookup. */
/* Do somethjing with the entry. */
dictFreeUnlinkedEntry(entry); /* No lookups!. */
Diffstat (limited to 'src/dict.h')
-rw-r--r-- | src/dict.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/dict.h b/src/dict.h index 739de68ef..406fa36d8 100644 --- a/src/dict.h +++ b/src/dict.h @@ -154,7 +154,8 @@ dictEntry *dictAddRaw(dict *d, void *key, dictEntry **existing); int dictReplace(dict *d, void *key, void *val); dictEntry *dictReplaceRaw(dict *d, void *key); int dictDelete(dict *d, const void *key); -int dictDeleteNoFree(dict *d, const void *key); +dictEntry *dictUnlink(dict *ht, const void *key); +void dictFreeUnlinkedEntry(dict *d, dictEntry *he); void dictRelease(dict *d); dictEntry * dictFind(dict *d, const void *key); void *dictFetchValue(dict *d, const void *key); |