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:
-rw-r--r--source/blender/blenlib/BLI_smallhash.h6
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c2
-rw-r--r--source/blender/blenlib/intern/edgehash.c2
-rw-r--r--source/blender/blenlib/intern/smallhash.c39
4 files changed, 20 insertions, 29 deletions
diff --git a/source/blender/blenlib/BLI_smallhash.h b/source/blender/blenlib/BLI_smallhash.h
index 7b591c071c6..84cd68e9d9c 100644
--- a/source/blender/blenlib/BLI_smallhash.h
+++ b/source/blender/blenlib/BLI_smallhash.h
@@ -49,9 +49,9 @@ typedef struct SmallHash {
SmallHashEntry _stacktable[SMSTACKSIZE];
SmallHashEntry _copytable[SMSTACKSIZE];
SmallHashEntry *stacktable, *copytable;
- int used;
- int curhash;
- int size;
+ unsigned int used;
+ unsigned int curhash;
+ unsigned int size;
} SmallHash;
typedef struct {
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 0887d646479..8c73cf8960c 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -42,7 +42,7 @@
#include "MEM_sys_types.h" /* for intptr_t support */
/***/
-unsigned int hashsizes[] = {
+const unsigned int 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,
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index d75ada9e799..5aa53f44519 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -41,7 +41,7 @@
#include "BLI_mempool.h"
/**************inlined code************/
-static unsigned int _ehash_hashsizes[] = {
+static const unsigned int _ehash_hashsizes[] = {
1, 3, 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,
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index c24b495bfb6..600433fe1b1 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -45,23 +45,14 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wstrict-overflow"
+# pragma GCC diagnostic error "-Wsign-conversion"
#endif
-BLI_INLINE int smhash_nonzero(const int n)
-{
- return n + !n;
-}
-
-BLI_INLINE int smhash_abs_i(const int n)
-{
- return (n > 0) ? n : -n;
-}
-
/* typically this re-assigns 'h' */
#define SMHASH_NEXT(h, hoff) ( \
- CHECK_TYPE_INLINE(&(h), int), \
- CHECK_TYPE_INLINE(&(hoff), int), \
- smhash_abs_i((h) + (((hoff) = smhash_nonzero((hoff) * 2) + 1), (hoff))) \
+ CHECK_TYPE_INLINE(&(h), unsigned int), \
+ CHECK_TYPE_INLINE(&(hoff), unsigned int), \
+ ((h) + (((hoff) = ((hoff) * 2) + 1), (hoff))) \
)
extern unsigned int hashsizes[];
@@ -94,10 +85,10 @@ void BLI_smallhash_release(SmallHash *hash)
void BLI_smallhash_insert(SmallHash *hash, uintptr_t key, void *item)
{
- int h, hoff = 1;
+ unsigned int h, hoff = 1;
if (hash->size < hash->used * 3) {
- int newsize = hashsizes[++hash->curhash];
+ unsigned int newsize = hashsizes[++hash->curhash];
SmallHashEntry *tmp;
int i = 0;
@@ -122,7 +113,7 @@ void BLI_smallhash_insert(SmallHash *hash, uintptr_t key, void *item)
continue;
}
- h = ABS((int)(tmp[i].key));
+ h = (unsigned int)(tmp[i].key);
hoff = 1;
while (!ELEM(hash->table[h % newsize].val, SMHASH_CELL_UNUSED, SMHASH_CELL_FREE)) {
h = SMHASH_NEXT(h, hoff);
@@ -139,7 +130,7 @@ void BLI_smallhash_insert(SmallHash *hash, uintptr_t key, void *item)
}
}
- h = ABS((int)key);
+ h = (unsigned int)(key);
hoff = 1;
while (!ELEM(hash->table[h % hash->size].val, SMHASH_CELL_UNUSED, SMHASH_CELL_FREE)) {
@@ -155,9 +146,9 @@ void BLI_smallhash_insert(SmallHash *hash, uintptr_t key, void *item)
void BLI_smallhash_remove(SmallHash *hash, uintptr_t key)
{
- int h, hoff = 1;
+ unsigned int h, hoff = 1;
- h = ABS((int)key);
+ h = (unsigned int)(key);
while ((hash->table[h % hash->size].key != key) ||
(hash->table[h % hash->size].val == SMHASH_CELL_UNUSED))
@@ -176,10 +167,10 @@ void BLI_smallhash_remove(SmallHash *hash, uintptr_t key)
void *BLI_smallhash_lookup(SmallHash *hash, uintptr_t key)
{
- int h, hoff = 1;
+ unsigned int h, hoff = 1;
void *v;
- h = ABS((int)key);
+ h = (unsigned int)(key);
while ((hash->table[h % hash->size].key != key) ||
(hash->table[h % hash->size].val == SMHASH_CELL_UNUSED))
@@ -202,8 +193,8 @@ void *BLI_smallhash_lookup(SmallHash *hash, uintptr_t key)
int BLI_smallhash_haskey(SmallHash *hash, uintptr_t key)
{
- int h = ABS((int)key);
- int hoff = 1;
+ unsigned int h = (unsigned int)(key);
+ unsigned int hoff = 1;
while ((hash->table[h % hash->size].key != key) ||
(hash->table[h % hash->size].val == SMHASH_CELL_UNUSED))
@@ -220,7 +211,7 @@ int BLI_smallhash_haskey(SmallHash *hash, uintptr_t key)
int BLI_smallhash_count(SmallHash *hash)
{
- return hash->used;
+ return (int)hash->used;
}
void *BLI_smallhash_iternext(SmallHashIter *iter, uintptr_t *key)