diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-08-18 07:41:39 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-08-18 07:41:39 +0400 |
commit | 754b4ab3bcbc92df0bcdff4848ef5ffc9410dce2 (patch) | |
tree | fa1dd64c56c0822962369d2d095f66b76f758e3a /source/blender/bmesh/intern/bmesh_log.c | |
parent | 7cce5563445a5363f9d125bf8c3cb30734cabdfe (diff) |
add hash function BLI_ghash_assign, BLI_edgehash_assign
avoids remove,insert and only hashes the key once.
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_log.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_log.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c index c7be4424a21..b50f35be4f3 100644 --- a/source/blender/bmesh/intern/bmesh_log.c +++ b/source/blender/bmesh/intern/bmesh_log.c @@ -117,10 +117,8 @@ static void bm_log_vert_id_set(BMLog *log, BMVert *v, unsigned int id) { void *vid = SET_INT_IN_POINTER(id); - BLI_ghash_remove(log->id_to_elem, vid, NULL, NULL); - BLI_ghash_insert(log->id_to_elem, vid, v); - BLI_ghash_remove(log->elem_to_id, v, NULL, NULL); - BLI_ghash_insert(log->elem_to_id, v, vid); + BLI_ghash_assign(log->id_to_elem, vid, v, NULL, NULL); + BLI_ghash_assign(log->elem_to_id, v, vid, NULL, NULL); } /* Get a vertex from its unique ID */ @@ -142,11 +140,9 @@ static unsigned int bm_log_face_id_get(BMLog *log, BMFace *f) static void bm_log_face_id_set(BMLog *log, BMFace *f, unsigned int id) { void *fid = SET_INT_IN_POINTER(id); - - BLI_ghash_remove(log->id_to_elem, fid, NULL, NULL); - BLI_ghash_insert(log->id_to_elem, fid, f); - BLI_ghash_remove(log->elem_to_id, f, NULL, NULL); - BLI_ghash_insert(log->elem_to_id, f, fid); + + BLI_ghash_assign(log->id_to_elem, fid, f, NULL, NULL); + BLI_ghash_assign(log->elem_to_id, f, fid, NULL, NULL); } /* Get a face from its unique ID */ |