diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-05-16 04:51:36 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-05-16 04:51:36 +0400 |
commit | ed33320e3f149f4106ed70b82d019113970c991e (patch) | |
tree | 49aaa5a8f7e53e7065fb758c86c73eddc20d3b9f /source/blender/blenlib | |
parent | eb22b5248229494bcab091e68cf7a354fe0cc0e3 (diff) |
Code cleanup: simplify standard GHash creation.
Added four new functions as shortcuts to creating GHashes that use the
standard ptr/str/int/pair hash and compare functions.
GHash *BLI_ghash_ptr_new(const char *info);
GHash *BLI_ghash_str_new(const char *info);
GHash *BLI_ghash_int_new(const char *info);
GHash *BLI_ghash_pair_new(const char *info);
Replaced almost all occurrences of BLI_ghash_new() with one of the
above functions.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_ghash.h | 5 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_ghash.c | 17 | ||||
-rw-r--r-- | source/blender/blenlib/intern/pbvh.c | 4 |
3 files changed, 24 insertions, 2 deletions
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index b2532d0e486..9034e8e51d9 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -147,6 +147,11 @@ int BLI_ghashutil_strcmp(const void *a, const void *b); unsigned int BLI_ghashutil_inthash(const void *ptr); int BLI_ghashutil_intcmp(const void *a, const void *b); +GHash *BLI_ghash_ptr_new(const char *info); +GHash *BLI_ghash_str_new(const char *info); +GHash *BLI_ghash_int_new(const char *info); +GHash *BLI_ghash_pair_new(const char *info); + typedef struct GHashPair { const void *first; const void *second; diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 6ec3d033672..5cfde3dfb77 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -305,6 +305,23 @@ int BLI_ghashutil_strcmp(const void *a, const void *b) return strcmp(a, b); } +GHash *BLI_ghash_ptr_new(const char *info) +{ + return BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, info); +} +GHash *BLI_ghash_str_new(const char *info) +{ + return BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, info); +} +GHash *BLI_ghash_int_new(const char *info) +{ + return BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, info); +} +GHash *BLI_ghash_pair_new(const char *info) +{ + return BLI_ghash_new(BLI_ghashutil_pairhash, BLI_ghashutil_paircmp, info); +} + GHashPair *BLI_ghashutil_pairalloc(const void *first, const void *second) { GHashPair *pair = MEM_mallocN(sizeof(GHashPair), "GHashPair"); diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index 73a90fa53a0..fdb0cc0ccc8 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -381,7 +381,7 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node) GHash *map; int i, j, totface; - map = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "build_mesh_leaf_node gh"); + map = BLI_ghash_int_new("build_mesh_leaf_node gh"); node->uniq_verts = node->face_verts = 0; totface = node->totprim; @@ -1262,7 +1262,7 @@ void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot unsigned i; int tot; - map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "pbvh_get_grid_updates gh"); + map = BLI_ghash_ptr_new("pbvh_get_grid_updates gh"); pbvh_iter_begin(&iter, bvh, NULL, NULL); |