[Bf-blender-cvs] [474362b363b] master: Cleanup: use 'uint'

Campbell Barton noreply at git.blender.org
Wed Nov 15 12:55:51 CET 2017


Commit: 474362b363b0fbb361401240b25fc1d2a272d910
Author: Campbell Barton
Date:   Wed Nov 15 22:50:25 2017 +1100
Branches: master
https://developer.blender.org/rB474362b363b0fbb361401240b25fc1d2a272d910

Cleanup: use 'uint'

===================================================================

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 5067a13cfa3..28e98c17a9d 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -53,7 +53,7 @@
 #define GHASH_USE_MODULO_BUCKETS
 
 /* Also used by smallhash! */
-const unsigned int hashsizes[] = {
+const uint hashsizes[] = {
 	5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, 
 	16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169, 
 	4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 
@@ -103,16 +103,16 @@ struct GHash {
 
 	Entry **buckets;
 	struct BLI_mempool *entrypool;
-	unsigned int nbuckets;
-	unsigned int limit_grow, limit_shrink;
+	uint nbuckets;
+	uint limit_grow, limit_shrink;
 #ifdef GHASH_USE_MODULO_BUCKETS
-	unsigned int cursize, size_min;
+	uint cursize, size_min;
 #else
-	unsigned int bucket_mask, bucket_bit, bucket_bit_min;
+	uint bucket_mask, bucket_bit, bucket_bit_min;
 #endif
 
-	unsigned int nentries;
-	unsigned int flag;
+	uint nentries;
+	uint flag;
 };
 
 
@@ -141,7 +141,7 @@ BLI_INLINE void ghash_entry_copy(
 /**
  * Get the full hash for a key.
  */
-BLI_INLINE unsigned int ghash_keyhash(GHash *gh, const void *key)
+BLI_INLINE uint ghash_keyhash(GHash *gh, const void *key)
 {
 	return gh->hashfp(key);
 }
@@ -149,7 +149,7 @@ BLI_INLINE unsigned int ghash_keyhash(GHash *gh, const void *key)
 /**
  * Get the full hash for an entry.
  */
-BLI_INLINE unsigned int ghash_entryhash(GHash *gh, const Entry *e)
+BLI_INLINE uint ghash_entryhash(GHash *gh, const Entry *e)
 {
 	return gh->hashfp(e->key);
 }
@@ -157,7 +157,7 @@ BLI_INLINE unsigned int ghash_entryhash(GHash *gh, const Entry *e)
 /**
  * Get the bucket-index for an already-computed full hash.
  */
-BLI_INLINE unsigned int ghash_bucket_index(GHash *gh, const unsigned int hash)
+BLI_INLINE uint ghash_bucket_index(GHash *gh, const uint hash)
 {
 #ifdef GHASH_USE_MODULO_BUCKETS
 	return hash % gh->nbuckets;
@@ -169,7 +169,7 @@ BLI_INLINE unsigned int ghash_bucket_index(GHash *gh, const unsigned int hash)
 /**
  * Find the index of next used bucket, starting from \a curr_bucket (\a gh is assumed non-empty).
  */
-BLI_INLINE unsigned int ghash_find_next_bucket_index(GHash *gh, unsigned int curr_bucket)
+BLI_INLINE uint ghash_find_next_bucket_index(GHash *gh, uint curr_bucket)
 {
 	if (curr_bucket >= gh->nbuckets) {
 		curr_bucket = 0;
@@ -194,12 +194,12 @@ BLI_INLINE unsigned int ghash_find_next_bucket_index(GHash *gh, unsigned int cur
 /**
  * Expand buckets to the next size up or down.
  */
-static void ghash_buckets_resize(GHash *gh, const unsigned int nbuckets)
+static void ghash_buckets_resize(GHash *gh, const uint nbuckets)
 {
 	Entry **buckets_old = gh->buckets;
 	Entry **buckets_new;
-	const unsigned int nbuckets_old = gh->nbuckets;
-	unsigned int i;
+	const uint nbuckets_old = gh->nbuckets;
+	uint i;
 
 	BLI_assert((gh->nbuckets != nbuckets) || !gh->buckets);
 //	printf("%s: %d -> %d\n", __func__, nbuckets_old, nbuckets);
@@ -261,9 +261,9 @@ static void ghash_buckets_resize(GHash *gh, const unsigned int nbuckets)
  * or small enough to require less buckets, and resize \a gh accordingly.
  */
 static void ghash_buckets_expand(
-        GHash *gh, const unsigned int nentries, const bool user_defined)
+        GHash *gh, const uint nentries, const bool user_defined)
 {
-	unsigned int new_nbuckets;
+	uint new_nbuckets;
 
 	if (LIKELY(gh->buckets && (nentries < gh->limit_grow))) {
 		return;
@@ -305,9 +305,9 @@ static void ghash_buckets_expand(
 }
 
 static void ghash_buckets_contract(
-        GHash *gh, const unsigned int nentries, const bool user_defined, const bool force_shrink)
+        GHash *gh, const uint nentries, const bool user_defined, const bool force_shrink)
 {
-	unsigned int new_nbuckets;
+	uint new_nbuckets;
 
 	if (!(force_shrink || (gh->flag & GHASH_FLAG_ALLOW_SHRINK))) {
 		return;
@@ -355,7 +355,7 @@ static void ghash_buckets_contract(
 /**
  * Clear and reset \a gh buckets, reserve again buckets for given number of entries.
  */
-BLI_INLINE void ghash_buckets_reset(GHash *gh, const unsigned int nentries)
+BLI_INLINE void ghash_buckets_reset(GHash *gh, const uint nentries)
 {
 	MEM_SAFE_FREE(gh->buckets);
 
@@ -383,7 +383,7 @@ BLI_INLINE void ghash_buckets_reset(GHash *gh, const unsigned int nentries)
  * Takes hash and bucket_index arguments to avoid calling #ghash_keyhash and #ghash_bucket_index multiple times.
  */
 BLI_INLINE Entry *ghash_lookup_entry_ex(
-        GHash *gh, const void *key, const unsigned int bucket_index)
+        GHash *gh, const void *key, const uint bucket_index)
 {
 	Entry *e;
 	/* If we do not store GHash, not worth computing it for each entry here!
@@ -404,7 +404,7 @@ BLI_INLINE Entry *ghash_lookup_entry_ex(
  */
 BLI_INLINE Entry *ghash_lookup_entry_prev_ex(
         GHash *gh, const void *key,
-        Entry **r_e_prev, const unsigned int bucket_index)
+        Entry **r_e_prev, const uint bucket_index)
 {
 	/* If we do not store GHash, not worth computing it for each entry here!
 	 * Typically, comparison function will be quicker, and since it's needed in the end anyway... */
@@ -424,13 +424,13 @@ BLI_INLINE Entry *ghash_lookup_entry_prev_ex(
  */
 BLI_INLINE Entry *ghash_lookup_entry(GHash *gh, const void *key)
 {
-	const unsigned int hash = ghash_keyhash(gh, key);
-	const unsigned int bucket_index = ghash_bucket_index(gh, hash);
+	const uint hash = ghash_keyhash(gh, key);
+	const uint bucket_index = ghash_bucket_index(gh, hash);
 	return ghash_lookup_entry_ex(gh, key, bucket_index);
 }
 
 static GHash *ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info,
-                        const unsigned int nentries_reserve, const unsigned int flag)
+                        const uint nentries_reserve, const uint flag)
 {
 	GHash *gh = MEM_mallocN(sizeof(*gh), info);
 
@@ -451,7 +451,7 @@ static GHash *ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info,
  * Takes hash and bucket_index arguments to avoid calling #ghash_keyhash and #ghash_bucket_index multiple times.
  */
 BLI_INLINE void ghash_insert_ex(
-        GHash *gh, void *key, void *val, const unsigned int bucket_index)
+        GHash *gh, void *key, void *val, const uint bucket_index)
 {
 	GHashEntry *e = BLI_mempool_alloc(gh->entrypool);
 
@@ -470,7 +470,7 @@ BLI_INLINE void ghash_insert_ex(
  * Insert function that takes a pre-allocated entry.
  */
 BLI_INLINE void ghash_insert_ex_keyonly_entry(
-        GHash *gh, void *key, const unsigned int bucket_index,
+        GHash *gh, void *key, const uint bucket_index,
         Entry *e)
 {
 	BLI_assert((gh->flag & GHASH_FLAG_ALLOW_DUPES) || (BLI_ghash_haskey(gh, key) == 0));
@@ -486,7 +486,7 @@ BLI_INLINE void ghash_insert_ex_keyonly_entry(
  * Insert function that doesn't set the value (use for GSet)
  */
 BLI_INLINE void ghash_insert_ex_keyonly(
-        GHash *gh, void *key, const unsigned int bucket_index)
+        GHash *gh, void *key, const uint bucket_index)
 {
 	Entry *e = BLI_mempool_alloc(gh->entrypool);
 
@@ -502,8 +502,8 @@ BLI_INLINE void ghash_insert_ex_keyonly(
 
 BLI_INLINE void ghash_insert(GHash *gh, void *key, void *val)
 {
-	const unsigned int hash = ghash_keyhash(gh, key);
-	const unsigned int bucket_index = ghash_bucket_index(gh, hash);
+	const uint hash = ghash_keyhash(gh, key);
+	const uint bucket_index = ghash_bucket_index(gh, hash);
 
 	ghash_insert_ex(gh, key, val, bucket_index);
 }
@@ -512,8 +512,8 @@ BLI_INLINE bool ghash_insert_safe(
         GHash *gh, void *key, void *val, const bool override,
         GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
 {
-	const unsigned int hash = ghash_keyhash(gh, key);
-	const unsigned int bucket_index = ghash_bucket_index(gh, hash);
+	const uint hash = ghash_keyhash(gh, key);
+	const uint bucket_index = ghash_bucket_index(gh, hash);
 	GHashEntry *e = (GHashEntry *)ghash_lookup_entry_ex(gh, key, bucket_index);
 
 	BLI_assert(!(gh->flag & GHASH_FLAG_IS_GSET));
@@ -541,8 +541,8 @@ BLI_INLINE bool ghash_insert_safe_keyonly(
         GHash *gh, void *key, const bool override,
         GHashKeyFreeFP keyfreefp)
 {
-	const unsigned int hash = ghash_keyhash(gh, key);
-	const unsigned int bucket_index = ghash_bucket_index(gh, hash);
+	const uint hash = ghash_keyhash(gh, key);
+	const uint bucket_index = ghash_bucket_index(gh, hash);
 	Entry *e = ghash_lookup_entry_ex(gh, key, bucket_index);
 
 	BLI_assert((gh->flag & GHASH_FLAG_IS_GSET) != 0);
@@ -568,7 +568,7 @@ BLI_INLINE bool ghash_insert_safe_keyonly(
 static Entry *ghash_remove_ex(
         GHash *gh, const void *key,
         GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp,
-        const unsigned int bucket_index)
+        const uint bucket_index)
 {
 	Entry *e_prev;
 	Entry *e = ghash_lookup_entry_prev_ex(gh, key, &e_prev, bucket_index);
@@ -601,7 +601,7 @@ static Entry *ghash_remove_ex(
  */
 static Entry *ghash_pop(GHash *gh, GHashIterState *state)
 {
-	unsigned int curr_bucket = state->curr_bucket;
+	uint curr_bucket = state->curr_bucket;
 	if (gh->nentries == 0) {
 		return NULL;
 	}
@@ -626,7 +626,7 @@ static void ghash_free_cb(
         GHash *gh,
         GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
 {
-	unsigned int i;
+	uint i;
 
 	BLI_assert(keyfreefp  || valfreefp);
 	BLI_assert(!valfreefp || !(gh->flag & GHASH_FLAG_IS_GSET));
@@ -651,9 +651,9 @@ static void ghash_free_cb(
 static GHash *ghash_copy(GHash *gh, GHashKeyCopyFP keycopyfp, GHashValCopyFP valcopyfp)
 {
 	GHash *gh_new;
-	unsigned int i;
+	uint i;
 	/* This allows us to be sure to get the same number of buckets in gh_new as in ghash. */
-	const unsigned int reserve_nentries_new = MAX2(GHASH_LIMIT_GROW(gh->nbuckets) - 1, gh->nentries);
+	const uint reserve_nentries_new = MAX2(GHASH_LIMIT_GROW(gh->nbuckets) - 1, gh->nentries);
 
 	BLI_assert(!valcopyfp || !(gh->flag & GHASH_FLAG_IS_GSET));
 
@@ -700,7 +700,7 @@ static GHash *ghash_copy(GHash *gh, GHashKeyCopyFP keycopyfp, GHashValCopyFP val
  * \return  An empty GHash.
  */
 GHash *BLI_ghash_new_ex(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info,
-                        const unsigned int nentries_reserve)
+                        const uint nentries_reserve)
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list