Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-11-29 09:11:40 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-11-29 09:51:12 +0300
commit09c2bff32f411e1c9f100526d04de6430fa8cc43 (patch)
tree4c70309a7042c2acbceed409c313997046086b90 /source/blender/blenlib/intern/BLI_ghash.c
parent472599402fcf1bc702afcf7729632d1a56770591 (diff)
Cleanup: rename `hash` -> `bucket_index`, edgehash API
Was confusing since a hash isn't typically used as an index on its own. Also C99 for loop for bucket resize loop.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_ghash.c')
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index a36a762a0e1..aa412fe005d 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -155,7 +155,7 @@ BLI_INLINE unsigned int ghash_entryhash(GHash *gh, const Entry *e)
}
/**
- * Get the bucket-hash for an already-computed full hash.
+ * Get the bucket-index for an already-computed full hash.
*/
BLI_INLINE unsigned int ghash_bucket_index(GHash *gh, const unsigned int hash)
{
@@ -175,7 +175,6 @@ static void ghash_buckets_resize(GHash *gh, const unsigned int nbuckets)
Entry **buckets_new;
const unsigned int nbuckets_old = gh->nbuckets;
unsigned int i;
- Entry *e;
BLI_assert((gh->nbuckets != nbuckets) || !gh->buckets);
// printf("%s: %d -> %d\n", __func__, nbuckets_old, nbuckets);
@@ -191,8 +190,7 @@ static void ghash_buckets_resize(GHash *gh, const unsigned int nbuckets)
if (buckets_old) {
if (nbuckets > nbuckets_old) {
for (i = 0; i < nbuckets_old; i++) {
- Entry *e_next;
- for (e = buckets_old[i]; e; e = e_next) {
+ for (Entry *e = buckets_old[i], *e_next; e; e = e_next) {
const unsigned hash = ghash_entryhash(gh, e);
const unsigned bucket_index = ghash_bucket_index(gh, hash);
e_next = e->next;
@@ -204,8 +202,7 @@ static void ghash_buckets_resize(GHash *gh, const unsigned int nbuckets)
else {
for (i = 0; i < nbuckets_old; i++) {
#ifdef GHASH_USE_MODULO_BUCKETS
- Entry *e_next;
- for (e = buckets_old[i]; e; e = e_next) {
+ for (Entry *e = buckets_old[i], *e_next; e; e = e_next) {
const unsigned hash = ghash_entryhash(gh, e);
const unsigned bucket_index = ghash_bucket_index(gh, hash);
e_next = e->next;
@@ -217,6 +214,7 @@ static void ghash_buckets_resize(GHash *gh, const unsigned int nbuckets)
* will go in same new bucket (i & new_mask)! */
const unsigned bucket_index = ghash_bucket_index(gh, i);
BLI_assert(!buckets_old[i] || (bucket_index == ghash_bucket_index(gh, ghash_entryhash(gh, buckets_old[i]))));
+ Entry *e;
for (e = buckets_old[i]; e && e->next; e = e->next);
if (e) {
e->next = buckets_new[bucket_index];
@@ -376,7 +374,7 @@ BLI_INLINE Entry *ghash_lookup_entry_ex(
/**
* Internal lookup function, returns previous entry of target one too.
- * Takes hash and bucket_index arguments to avoid calling #ghash_keyhash and #ghash_bucket_index multiple times.
+ * Takes bucket_index argument to avoid calling #ghash_keyhash and #ghash_bucket_index multiple times.
* Useful when modifying buckets somehow (like removing an entry...).
*/
BLI_INLINE Entry *ghash_lookup_entry_prev_ex(