diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 467723e5e0a..f58034c1066 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, ®ion_out); + + c = loop_find_region(l, BM_ELEM_SELECT, visit_face_set, ®ion_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; }