[Bf-blender-cvs] [53c106a] temp-ghash-basis: pass flag directly to internal ghash_new function
Campbell Barton
noreply at git.blender.org
Thu Mar 19 17:06:53 CET 2015
Commit: 53c106ae127e3e4eb9c016a5c36ef3c2bcc22efb
Author: Campbell Barton
Date: Fri Mar 20 03:04:20 2015 +1100
Branches: temp-ghash-basis
https://developer.blender.org/rB53c106ae127e3e4eb9c016a5c36ef3c2bcc22efb
pass flag directly to internal ghash_new function
===================================================================
M source/blender/blenlib/intern/BLI_ghash.c
===================================================================
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index a9406fc..41e5cbb 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -95,7 +95,7 @@ typedef struct GHashEntry {
typedef Entry GSetEntry;
#define GHASH_ENTRY_SIZE(_is_gset) \
- (_is_gset) ? sizeof(GSetEntry) : sizeof(GHashEntry)
+ ((_is_gset) ? sizeof(GSetEntry) : sizeof(GHashEntry))
struct GHash {
GHashHashFP hashfp;
@@ -409,7 +409,7 @@ BLI_INLINE Entry *ghash_lookup_entry(GHash *gh, const void *key)
}
static GHash *ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info,
- const unsigned int nentries_reserve, const bool is_gset)
+ const unsigned int nentries_reserve, const unsigned int flag)
{
GHash *gh = MEM_mallocN(sizeof(*gh), info);
@@ -418,10 +418,8 @@ static GHash *ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info,
gh->buckets = NULL;
ghash_buckets_reset(gh, nentries_reserve);
- gh->entrypool = BLI_mempool_create((unsigned int)GHASH_ENTRY_SIZE(is_gset), 64, 64, BLI_MEMPOOL_NOP);
- if (is_gset) {
- gh->flag |= GHASH_FLAG_IS_GSET;
- }
+ gh->entrypool = BLI_mempool_create(GHASH_ENTRY_SIZE(flag & GHASH_FLAG_IS_GSET), 64, 64, BLI_MEMPOOL_NOP);
+ gh->flag |= flag;
return gh;
}
@@ -569,11 +567,10 @@ static GHash *ghash_copy(GHash *gh, GHashKeyCopyFP keycopyfp, GHashValCopyFP val
{
GHash *gh_new;
unsigned int i;
- const bool is_gset = (gh->flag & GHASH_FLAG_IS_GSET) != 0;
- BLI_assert(!valcopyfp || !is_gset);
+ BLI_assert(!valcopyfp || !(gh->flag & GHASH_FLAG_IS_GSET));
- gh_new = ghash_new(gh->hashfp, gh->cmpfp, __func__, 0, is_gset);
+ gh_new = ghash_new(gh->hashfp, gh->cmpfp, __func__, 0, gh->flag & GHASH_FLAG_IS_GSET);
ghash_buckets_expand(gh_new, gh->nentries, false);
for (i = 0; i < gh->nbuckets; i++) {
@@ -620,7 +617,7 @@ static GHash *ghash_copy(GHash *gh, GHashKeyCopyFP keycopyfp, GHashValCopyFP val
GHash *BLI_ghash_new_ex(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info,
const unsigned int nentries_reserve)
{
- return ghash_new(hashfp, cmpfp, info, nentries_reserve, false);
+ return ghash_new(hashfp, cmpfp, info, nentries_reserve, 0);
}
/**
@@ -1179,7 +1176,7 @@ GHash *BLI_ghash_pair_new(const char *info)
GSet *BLI_gset_new_ex(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info,
const unsigned int nentries_reserve)
{
- return (GSet *)ghash_new(hashfp, cmpfp, info, nentries_reserve, true);
+ return (GSet *)ghash_new(hashfp, cmpfp, info, nentries_reserve, GHASH_FLAG_IS_GSET);
}
GSet *BLI_gset_new(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info)
More information about the Bf-blender-cvs
mailing list