diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-08-17 12:00:22 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-08-17 12:00:22 +0400 |
commit | 85b0315b3bae9e699021977f9b40d504d9a9d108 (patch) | |
tree | 0777800d7d8cf2d3569493c2e4b937480fe1910b /source/blender | |
parent | 1b11428101d390e482f6a67adba27f42cda7f4a8 (diff) |
avoid double ghash lookups
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/bmesh/operators/bmo_symmetrize.c | 12 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_uv.c | 5 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_smart_stitch.c | 5 |
3 files changed, 12 insertions, 10 deletions
diff --git a/source/blender/bmesh/operators/bmo_symmetrize.c b/source/blender/bmesh/operators/bmo_symmetrize.c index b684240dc76..620bbafc372 100644 --- a/source/blender/bmesh/operators/bmo_symmetrize.c +++ b/source/blender/bmesh/operators/bmo_symmetrize.c @@ -101,7 +101,7 @@ static void symm_verts_mirror(Symm *symm) BMOIter oiter; BMVert *src_v, *dst_v; - symm->vert_symm_map = BLI_ghash_ptr_new(AT); + symm->vert_symm_map = BLI_ghash_ptr_new(__func__); BMO_ITER (src_v, &oiter, symm->op->slots_in, "input", BM_VERT) { SymmSide side = symm_co_side(symm, src_v->co); @@ -214,9 +214,8 @@ static void symm_mirror_edges(Symm *symm) BMO_elem_flag_enable(symm->bm, e_new, SYMM_OUTPUT_GEOM); } else if (v1 || v2) { - if (BLI_ghash_haskey(symm->edge_split_map, e)) { - BMVert *v_split = BLI_ghash_lookup(symm->edge_split_map, e); - + BMVert *v_split = BLI_ghash_lookup(symm->edge_split_map, e); + if (v_split) { /* Output the keep side of the split edge */ if (!v1) { e_new = BM_edge_create(symm->bm, v_split, e->v2, e, BM_CREATE_NO_DOUBLE); @@ -330,8 +329,9 @@ static BMVert *symm_poly_mirror_dst(const Symm *symm, if (sp->edge_verts[v]) return sp->edge_verts[v]; else if (sp->src_verts[v]) { - if (BLI_ghash_haskey(symm->vert_symm_map, sp->src_verts[v])) - return BLI_ghash_lookup(symm->vert_symm_map, sp->src_verts[v]); + BMVert *v_src = BLI_ghash_lookup(symm->vert_symm_map, sp->src_verts[v]); + if (v_src) + return v_src; else return sp->src_verts[v]; } diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 9c73d4d9477..d630b6478fb 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -662,6 +662,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { int offset1, itmp1 = uv_element_offset_from_face_get(data->elementMap, efa, l, island_index, do_island_optimization); int offset2, itmp2 = uv_element_offset_from_face_get(data->elementMap, efa, l->next, island_index, do_island_optimization); + char *flag; /* Skip edge if not found(unlikely) or not on valid island */ if (itmp1 == -1 || itmp2 == -1) @@ -682,8 +683,8 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm edges[counter].uv2 = offset1; } /* Hack! Set the value of the key to its flag. Now we can set the flag when an edge exists twice :) */ - if (BLI_ghash_haskey(edgeHash, &edges[counter])) { - char *flag = BLI_ghash_lookup(edgeHash, &edges[counter]); + flag = BLI_ghash_lookup(edgeHash, &edges[counter]); + if (flag) { *flag = 1; } else { diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 3318ae72624..f788c6a772c 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -1718,6 +1718,7 @@ static int stitch_init(bContext *C, wmOperator *op) UvElement *element = ED_uv_element_get(state->element_map, efa, l); int offset1, itmp1 = element - state->element_map->buf; int offset2, itmp2 = ED_uv_element_get(state->element_map, efa, l->next) - state->element_map->buf; + UvEdge *edge; offset1 = map[itmp1]; offset2 = map[itmp2]; @@ -1737,8 +1738,8 @@ static int stitch_init(bContext *C, wmOperator *op) all_edges[counter].uv2 = offset1; } - if (BLI_ghash_haskey(edge_hash, &all_edges[counter])) { - UvEdge *edge = BLI_ghash_lookup(edge_hash, &all_edges[counter]); + edge = BLI_ghash_lookup(edge_hash, &all_edges[counter]); + if (edge) { edge->flag = 0; } else { |