[Bf-blender-cvs] [9db947d] master: Editmesh: Replace SmallHash with GSet for MESH_OT_loop_to_region

Campbell Barton noreply at git.blender.org
Fri Jun 13 16:48:01 CEST 2014


Commit: 9db947df41204b3b19e649a54669655642402300
Author: Campbell Barton
Date:   Thu May 29 14:03:22 2014 +1000
https://developer.blender.org/rB9db947df41204b3b19e649a54669655642402300

Editmesh: Replace SmallHash with GSet for MESH_OT_loop_to_region

There no reason to assume hash will be small in this case

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

M	source/blender/editors/mesh/editmesh_select.c

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

diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 467723e..f58034c 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -3189,7 +3189,7 @@ void MESH_OT_region_to_loop(wmOperatorType *ot)
 }
 
 static int loop_find_region(BMLoop *l, int flag,
-                            SmallHash *fhash, BMFace ***region_out)
+                            GSet *visit_face_set, BMFace ***region_out)
 {
 	BMFace **region = NULL;
 	BMFace **stack = NULL;
@@ -3198,7 +3198,7 @@ static int loop_find_region(BMLoop *l, int flag,
 	BMFace *f;
 	
 	BLI_array_append(stack, l->f);
-	BLI_smallhash_insert(fhash, (uintptr_t)l->f, NULL);
+	BLI_gset_insert(visit_face_set, l->f);
 	
 	while (BLI_array_count(stack) > 0) {
 		BMIter liter1, liter2;
@@ -3217,11 +3217,10 @@ static int loop_find_region(BMLoop *l, int flag,
 				if (BM_elem_flag_test(l2->f, BM_ELEM_TAG)) {
 					continue;
 				}
-				if (BLI_smallhash_haskey(fhash, (uintptr_t)l2->f))
-					continue;
-				
-				BLI_array_append(stack, l2->f);
-				BLI_smallhash_insert(fhash, (uintptr_t)l2->f, NULL);
+
+				if (BLI_gset_add(visit_face_set, l2->f)) {
+					BLI_array_append(stack, l2->f);
+				}
 			}
 		}
 	}
@@ -3254,13 +3253,13 @@ static int verg_radial(const void *va, const void *vb)
  */
 static int loop_find_regions(BMEditMesh *em, const bool selbigger)
 {
-	SmallHash visithash;
+	GSet *visit_face_set;
 	BMIter iter;
 	const int edges_len = em->bm->totedgesel;
 	BMEdge *e, **edges;
 	int count = 0, i;
 	
-	BLI_smallhash_init_ex(&visithash, edges_len);
+	visit_face_set = BLI_gset_ptr_new_ex(__func__, edges_len);
 	edges = MEM_mallocN(sizeof(*edges) * edges_len, __func__);
 
 	i = 0;
@@ -3289,10 +3288,10 @@ static int loop_find_regions(BMEditMesh *em, const bool selbigger)
 			continue;
 		
 		BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) {
-			if (BLI_smallhash_haskey(&visithash, (uintptr_t)l->f))
+			if (BLI_gset_haskey(visit_face_set, l->f))
 				continue;
-						
-			c = loop_find_region(l, BM_ELEM_SELECT, &visithash, &region_out);
+
+			c = loop_find_region(l, BM_ELEM_SELECT, visit_face_set, &region_out);
 
 			if (!region || (selbigger ? c >= tot : c < tot)) {
 				/* this region is the best seen so far */
@@ -3327,7 +3326,7 @@ static int loop_find_regions(BMEditMesh *em, const bool selbigger)
 	}
 	
 	MEM_freeN(edges);
-	BLI_smallhash_release(&visithash);
+	BLI_gset_free(visit_face_set, NULL);
 	
 	return count;
 }




More information about the Bf-blender-cvs mailing list