From bc3cb6ff766eadeeb358dbf2fac5a76db58355db Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 3 Feb 2013 15:03:55 +0000 Subject: [PATCH] remove paranoid null check from BLI_ghash_lookup(), was the only ghash function with a null check, callers better check the ghash exists first. --- source/blender/blenlib/intern/BLI_ghash.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 7d2fc38272d..7ebe4430e20 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -78,9 +78,9 @@ void BLI_ghash_insert(GHash *gh, void *key, void *val) unsigned int hash = gh->hashfp(key) % gh->nbuckets; Entry *e = (Entry *)BLI_mempool_alloc(gh->entrypool); + e->next = gh->buckets[hash]; e->key = key; e->val = val; - e->next = gh->buckets[hash]; gh->buckets[hash] = e; if (++gh->nentries > (float)gh->nbuckets / 2) { @@ -109,13 +109,13 @@ void BLI_ghash_insert(GHash *gh, void *key, void *val) void *BLI_ghash_lookup(GHash *gh, const void *key) { - if (gh) { - unsigned int hash = gh->hashfp(key) % gh->nbuckets; - Entry *e; + const unsigned int hash = gh->hashfp(key) % gh->nbuckets; + Entry *e; - for (e = gh->buckets[hash]; e; e = e->next) - if (gh->cmpfp(key, e->key) == 0) - return e->val; + for (e = gh->buckets[hash]; e; e = e->next) { + if (gh->cmpfp(key, e->key) == 0) { + return e->val; + } } return NULL; }