diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-04-11 16:36:37 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-04-11 16:36:37 +0300 |
commit | ccf44c400c896761c87836a06be24216c366c87b (patch) | |
tree | 5b6b677b19008c1eb2d89b6c172c33622a698c7c /source | |
parent | 7447a0173cc841a1e9bd3f655c3230382c1e7cb7 (diff) |
BMesh: simplify hashing for dyntopo
Was using pointer hashing when the keys are in fact uint's.
Since they're well distributed from the rangetree,
no need to do bit-shifting tricks. just use int as hash.
Gives ~8% speedup in own tests.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/BLI_ghash.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_ghash.c | 5 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_log.c | 16 |
3 files changed, 16 insertions, 6 deletions
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index a00ddeefb2b..f287cf71f53 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -148,6 +148,7 @@ bool BLI_ghashutil_strcmp(const void *a, const void *b); unsigned int BLI_ghashutil_uinthash(unsigned int key); unsigned int BLI_ghashutil_inthash_p(const void *ptr); unsigned int BLI_ghashutil_inthash_p_murmur(const void *ptr); +unsigned int BLI_ghashutil_inthash_p_simple(const void *ptr); bool BLI_ghashutil_intcmp(const void *a, const void *b); diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index dae7af6a927..484fe70104e 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -1091,6 +1091,11 @@ unsigned int BLI_ghashutil_inthash_p_murmur(const void *ptr) return BLI_hash_mm2((const unsigned char *)&key, sizeof(key), 0); } +unsigned int BLI_ghashutil_inthash_p_simple(const void *ptr) +{ + return GET_UINT_FROM_POINTER(ptr); +} + bool BLI_ghashutil_intcmp(const void *a, const void *b) { return (a != b); diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c index c53b7f939c9..25ddb9ea79e 100644 --- a/source/blender/bmesh/intern/bmesh_log.c +++ b/source/blender/bmesh/intern/bmesh_log.c @@ -126,6 +126,10 @@ typedef struct { /************************* Get/set element IDs ************************/ +/* bypass actual hashing, the keys don't overlap */ +#define logkey_hash BLI_ghashutil_inthash_p_simple +#define logkey_cmp BLI_ghashutil_intcmp + /* Get the vertex's unique ID from the log */ static unsigned int bm_log_vert_id_get(BMLog *log, BMVert *v) { @@ -386,12 +390,12 @@ static BMLogEntry *bm_log_entry_create(void) { BMLogEntry *entry = MEM_callocN(sizeof(BMLogEntry), __func__); - entry->deleted_verts = BLI_ghash_ptr_new(__func__); - entry->deleted_faces = BLI_ghash_ptr_new(__func__); - entry->added_verts = BLI_ghash_ptr_new(__func__); - entry->added_faces = BLI_ghash_ptr_new(__func__); - entry->modified_verts = BLI_ghash_ptr_new(__func__); - entry->modified_faces = BLI_ghash_ptr_new(__func__); + entry->deleted_verts = BLI_ghash_new(logkey_hash, logkey_cmp, __func__); + entry->deleted_faces = BLI_ghash_new(logkey_hash, logkey_cmp, __func__); + entry->added_verts = BLI_ghash_new(logkey_hash, logkey_cmp, __func__); + entry->added_faces = BLI_ghash_new(logkey_hash, logkey_cmp, __func__); + entry->modified_verts = BLI_ghash_new(logkey_hash, logkey_cmp, __func__); + entry->modified_faces = BLI_ghash_new(logkey_hash, logkey_cmp, __func__); entry->pool_verts = BLI_mempool_create(sizeof(BMLogVert), 0, 64, BLI_MEMPOOL_NOP); entry->pool_faces = BLI_mempool_create(sizeof(BMLogFace), 0, 64, BLI_MEMPOOL_NOP); |