summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-04-10 17:44:27 +0000
committerBrian Paul <[email protected]>2005-04-10 17:44:27 +0000
commitaaa5a664331600139347039419cd5c8d9493b8aa (patch)
treeb53c879b0b6512490c944c68d9a43ff35bfe349e
parent5f92c38f0efddf575466381a2ab47046255b29f1 (diff)
set table size to 1023 and use new HASH_FUNC() macro
-rw-r--r--src/mesa/main/hash.c13
1 files changed, 8 insertions, 5 deletions
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) {