Fix pow <small> and a very stypid bug with dummy srcs(0 equals to tmp0.x)</small...
[mesa.git] / src / mesa / main / hash.c
index 01a8bd5e7ec4b40d72eea88e0c46a9cd455afb44..74ab57df0acefaee89efad24685497e2467bf7fb 100644 (file)
@@ -12,7 +12,7 @@
 
 /*
  * Mesa 3-D graphics library
- * Version:  6.3
+ * Version:  6.4
  *
  * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
  *
@@ -43,6 +43,9 @@
 
 #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) {
@@ -381,6 +384,8 @@ _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys)
 }
 
 
+#if 0 /* debug only */
+
 /**
  * Test walking over all the entries in a hash table.
  */
@@ -442,3 +447,5 @@ _mesa_test_hash_functions(void)
 
    test_hash_walking();
 }
+
+#endif