minor dyntopo speedup: was doing 2x ghash lookups for BM_log_face_removed(), BM_log_v...
authorCampbell Barton <ideasman42@gmail.com>
Sat, 19 Jan 2013 00:53:33 +0000 (00:53 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 19 Jan 2013 00:53:33 +0000 (00:53 +0000)
source/blender/bmesh/intern/bmesh_log.c

index 2ad65bead07a1bfe71bf21a1a2d0def4faeadac2..fa5bfe34a119d9d8607725ae5aa852e4ea921a14 100644 (file)
@@ -806,8 +806,11 @@ void BM_log_vert_removed(BMesh *bm, BMLog *log, BMVert *v)
        unsigned int v_id = bm_log_vert_id_get(log, v);
        void *key = SET_INT_IN_POINTER(v_id);
 
-       if (BLI_ghash_lookup(entry->added_verts, key)) {
-               BLI_ghash_remove(entry->added_verts, key, NULL, NULL);
+       /* if it has a key, it shouldn't be NULL */
+       BLI_assert(!!BLI_ghash_lookup(entry->added_verts, key) ==
+                  !!BLI_ghash_haskey(entry->added_verts, key));
+
+       if (BLI_ghash_remove(entry->added_verts, key, NULL, NULL)) {
                range_tree_uint_release(log->unused_ids, v_id);
        }
        else {
@@ -844,8 +847,11 @@ void BM_log_face_removed(BMLog *log, BMFace *f)
        unsigned int f_id = bm_log_face_id_get(log, f);
        void *key = SET_INT_IN_POINTER(f_id);
 
-       if (BLI_ghash_lookup(entry->added_faces, key)) {
-               BLI_ghash_remove(entry->added_faces, key, NULL, NULL);
+       /* if it has a key, it shouldn't be NULL */
+       BLI_assert(!!BLI_ghash_lookup(entry->added_faces, key) ==
+                  !!BLI_ghash_haskey(entry->added_faces, key));
+
+       if (BLI_ghash_remove(entry->added_faces, key, NULL, NULL)) {
                range_tree_uint_release(log->unused_ids, f_id);
        }
        else {