[Bf-blender-cvs] [f608236] temp-array-modifier: Replace GHash with GSet
Campbell Barton
noreply at git.blender.org
Tue Aug 12 05:40:08 CEST 2014
Commit: f6082365b3055ba401cd3fa5495571ad31479227
Author: Campbell Barton
Date: Tue Aug 12 13:39:32 2014 +1000
Branches: temp-array-modifier
https://developer.blender.org/rBf6082365b3055ba401cd3fa5495571ad31479227
Replace GHash with GSet
===================================================================
M source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 9d3977d..5795506 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -2715,13 +2715,13 @@ typedef struct PolyKey {
} PolyKey;
-static unsigned int poly_ghash_hash_fn(const void *key)
+static unsigned int poly_gset_hash_fn(const void *key)
{
const PolyKey *pk = key;
return pk->hash_sum;
}
-static int poly_ghash_compare_fn(const void *k1, const void *k2)
+static int poly_gset_compare_fn(const void *k1, const void *k2)
{
const PolyKey *pk1 = k1;
const PolyKey *pk2 = k2;
@@ -2808,7 +2808,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
int i, j, c;
PolyKey *poly_keys;
- GHash *poly_ghash = NULL;
+ GSet *poly_gset = NULL;
STACK_INIT(oldv, totvert_final);
STACK_INIT(olde, totedge);
@@ -2878,9 +2878,9 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
/* This poly equality check is rather complex. We use a BLI_ghash to speed it up with a first level check */
PolyKey *mpgh;
poly_keys = MEM_mallocN(sizeof(PolyKey) * totpoly, __func__);
- poly_ghash = BLI_ghash_new_ex(poly_ghash_hash_fn, poly_ghash_compare_fn, __func__, totpoly);
+ poly_gset = BLI_gset_new_ex(poly_gset_hash_fn, poly_gset_compare_fn, __func__, totpoly);
/* Duplicates allowed because our compare function is not pure equality */
- BLI_ghash_flag_set(poly_ghash, GHASH_FLAG_ALLOW_DUPES);
+ BLI_gset_flag_set(poly_gset, GHASH_FLAG_ALLOW_DUPES);
mp = cddm->mpoly;
mpgh = poly_keys;
@@ -2893,7 +2893,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
mpgh->hash_sum += ml->v;
mpgh->hash_xor ^= ml->v;
}
- BLI_ghash_insert(poly_ghash, mpgh, mpgh);
+ BLI_gset_insert(poly_gset, mpgh);
}
if (cddm->pmap) {
@@ -2937,9 +2937,8 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
int i_poly, v_target, v_prev;
bool found = false;
PolyKey pkey;
- PolyKey *pkey_found;
- /* Use poly_ghash for fast (although not 100% certain) identification of same poly */
+ /* Use poly_gset for fast (although not 100% certain) identification of same poly */
/* First, make up a poly_summary structure */
ml = cddm->mloop + mp->loopstart;
pkey.hash_sum = pkey.hash_xor = 0;
@@ -2957,7 +2956,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
pkey.totloops++;
v_prev = v_target;
}
- if ((pkey_found = BLI_ghash_lookup(poly_ghash, &pkey))) {
+ if (BLI_gset_haskey(poly_gset, &pkey)) {
/* There might be a poly that matches this one.
* We could just leave it there and say there is, and do a "continue".
@@ -3029,10 +3028,10 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
} /* end of the loop that tests polys */
- if (poly_ghash) {
- // printf("hash quality %.6f\n", BLI_ghash_calc_quality(poly_ghash));
+ if (poly_gset) {
+ // printf("hash quality %.6f\n", BLI_gset_calc_quality(poly_gset));
- BLI_ghash_free(poly_ghash, NULL, NULL);
+ BLI_gset_free(poly_gset, NULL);
MEM_freeN(poly_keys);
}
More information about the Bf-blender-cvs
mailing list