[Bf-blender-cvs] [d0a4d37] temp-ghash-basis: Shrink: Early return in case we are not allowed to shrink.

Bastien Montagne noreply at git.blender.org
Thu Mar 19 16:51:29 CET 2015


Commit: d0a4d373eba063ffcab5e3882315de642456a2f9
Author: Bastien Montagne
Date:   Thu Mar 19 16:50:49 2015 +0100
Branches: temp-ghash-basis
https://developer.blender.org/rBd0a4d373eba063ffcab5e3882315de642456a2f9

Shrink: Early return in case we are not allowed to shrink.

===================================================================

M	source/blender/blenlib/intern/BLI_ghash.c

===================================================================

diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 4f5405b..6d6db6a 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -286,29 +286,31 @@ static void ghash_buckets_shrink(
 {
 	unsigned int new_nbuckets;
 
+	if (!(force_shrink || (gh->flag & GHASH_FLAG_ALLOW_SHRINK))) {
+		return;
+	}
+
 	if (LIKELY(gh->buckets && (nentries > gh->limit_shrink))) {
 		return;
 	}
 
 	new_nbuckets = gh->nbuckets;
 
-	if (force_shrink || (gh->flag & GHASH_FLAG_ALLOW_SHRINK)) {
 #ifdef GHASH_USE_MODULO_BUCKETS
-		while ((nentries    < gh->limit_shrink) &&
-		       (gh->cursize > gh->size_min))
-		{
-			new_nbuckets = hashsizes[--gh->cursize];
-			gh->limit_shrink = GHASH_LIMIT_SHRINK(new_nbuckets);
-		}
+	while ((nentries    < gh->limit_shrink) &&
+		   (gh->cursize > gh->size_min))
+	{
+		new_nbuckets = hashsizes[--gh->cursize];
+		gh->limit_shrink = GHASH_LIMIT_SHRINK(new_nbuckets);
+	}
 #else
-		while ((nentries       < gh->limit_shrink) &&
-		       (gh->bucket_bit > gh->bucket_bit_min))
-		{
-			new_nbuckets = 1u << --gh->bucket_bit;
-			gh->limit_shrink = GHASH_LIMIT_SHRINK(new_nbuckets);
-		}
-#endif
+	while ((nentries       < gh->limit_shrink) &&
+		   (gh->bucket_bit > gh->bucket_bit_min))
+	{
+		new_nbuckets = 1u << --gh->bucket_bit;
+		gh->limit_shrink = GHASH_LIMIT_SHRINK(new_nbuckets);
 	}
+#endif
 
 	if (user_defined) {
 #ifdef GHASH_USE_MODULO_BUCKETS




More information about the Bf-blender-cvs mailing list