From 58e1c9c143e9c5f108ca1863bdd61fc5e02dc968 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 16 Apr 2010 10:04:51 +0200 Subject: [PATCH] added dictFetchValue() to dict.c to make hash table API a bit less verbose in the common cases --- dict.c | 7 +++++++ dict.h | 1 + 2 files changed, 8 insertions(+) diff --git a/dict.c b/dict.c index 08bffbff8..d5010708c 100644 --- a/dict.c +++ b/dict.c @@ -423,6 +423,13 @@ dictEntry *dictFind(dict *d, const void *key) return NULL; } +void *dictFetchValue(dict *d, const void *key) { + dictEntry *he; + + he = dictFind(d,key); + return he ? dictGetEntryVal(he) : NULL; +} + dictIterator *dictGetIterator(dict *d) { dictIterator *iter = _dictAlloc(sizeof(*iter)); diff --git a/dict.h b/dict.h index ba8f86951..30ace4db7 100644 --- a/dict.h +++ b/dict.h @@ -129,6 +129,7 @@ int dictDelete(dict *d, const void *key); int dictDeleteNoFree(dict *d, const void *key); void dictRelease(dict *d); dictEntry * dictFind(dict *d, const void *key); +void *dictFetchValue(dict *d, const void *key); int dictResize(dict *d); dictIterator *dictGetIterator(dict *d); dictEntry *dictNext(dictIterator *iter); -- GitLab