Permalink
Browse files

added dictFetchValue() to dict.c to make hash table API a bit less ve…

…rbose in the common cases
  • Loading branch information...
1 parent d4dd655 commit 58e1c9c143e9c5f108ca1863bdd61fc5e02dc968 @antirez committed Apr 16, 2010
Showing with 8 additions and 0 deletions.
  1. +7 −0 dict.c
  2. +1 −0 dict.h
View
7 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));
View
1 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);

0 comments on commit 58e1c9c

Please sign in to comment.