From aaa5a664331600139347039419cd5c8d9493b8aa Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 10 Apr 2005 17:44:27 +0000 Subject: set table size to 1023 and use new HASH_FUNC() macro --- src/mesa/main/hash.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index 0861af1055d..924fd69e201 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -41,7 +41,10 @@ #include "hash.h" -#define TABLE_SIZE 1024 /**< Size of lookup table/array */ +#define TABLE_SIZE 1023 /**< Size of lookup table/array */ + +#define HASH_FUNC(K) ((K) % TABLE_SIZE) + /** * An entry in the hash table. @@ -127,7 +130,7 @@ _mesa_HashLookup(const struct _mesa_HashTable *table, GLuint key) assert(table); assert(key); - pos = key & (TABLE_SIZE-1); + pos = HASH_FUNC(key); entry = table->Table[pos]; while (entry) { if (entry->Key == key) { @@ -163,7 +166,7 @@ _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data) if (key > table->MaxKey) table->MaxKey = key; - pos = key & (TABLE_SIZE-1); + pos = HASH_FUNC(key); entry = table->Table[pos]; while (entry) { if (entry->Key == key) { @@ -207,7 +210,7 @@ _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key) _glthread_LOCK_MUTEX(table->Mutex); - pos = key & (TABLE_SIZE-1); + pos = HASH_FUNC(key); prev = NULL; entry = table->Table[pos]; while (entry) { @@ -278,7 +281,7 @@ _mesa_HashNextEntry(const struct _mesa_HashTable *table, GLuint key) assert(key); /* Find the entry with given key */ - pos = key & (TABLE_SIZE - 1); + pos = HASH_FUNC(key); entry = table->Table[pos]; while (entry) { if (entry->Key == key) { -- cgit v1.2.3