[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54277] trunk/blender/source/blender/ blenlib/intern/BLI_ghash.c: remove paranoid null check from BLI_ghash_lookup(), was the only ghash function with a null check, callers better check the ghash exists first.

Campbell Barton ideasman42 at gmail.com
Sun Feb 3 16:03:56 CET 2013


Revision: 54277
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54277
Author:   campbellbarton
Date:     2013-02-03 15:03:55 +0000 (Sun, 03 Feb 2013)
Log Message:
-----------
remove paranoid null check from BLI_ghash_lookup(), was the only ghash function with a null check, callers better check the ghash exists first.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/BLI_ghash.c

Modified: trunk/blender/source/blender/blenlib/intern/BLI_ghash.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/BLI_ghash.c	2013-02-03 13:10:56 UTC (rev 54276)
+++ trunk/blender/source/blender/blenlib/intern/BLI_ghash.c	2013-02-03 15:03:55 UTC (rev 54277)
@@ -78,9 +78,9 @@
 	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_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;
 }




More information about the Bf-blender-cvs mailing list