[Mesa-dev] [PATCH] mesa: use pre_hashed version of search for the mesa hash table

Timothy Arceri tarceri at itsqueeze.com
Tue Apr 11 01:05:35 UTC 2017


The key is just an unsigned int so there is never any real hashing
done.
---
 src/mesa/main/hash.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c
index 670438a..eb25d88 100644
--- a/src/mesa/main/hash.c
+++ b/src/mesa/main/hash.c
@@ -176,21 +176,22 @@ static inline void *
 _mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key)
 {
    const struct hash_entry *entry;
 
    assert(table);
    assert(key);
 
    if (key == DELETED_KEY_VALUE)
       return table->deleted_key_data;
 
-   entry = _mesa_hash_table_search(table->ht, uint_key(key));
+   uint32_t hash = uint_hash(key);
+   entry = _mesa_hash_table_search_pre_hashed(table->ht, hash, uint_key(key));
    if (!entry)
       return NULL;
 
    return entry->data;
 }
 
 
 /**
  * Lookup an entry in the hash table.
  * 
@@ -340,21 +341,23 @@ _mesa_HashRemove_unlocked(struct _mesa_HashTable *table, GLuint key)
    /* have to check this outside of mutex lock */
    if (table->InDeleteAll) {
       _mesa_problem(NULL, "_mesa_HashRemove illegally called from "
                     "_mesa_HashDeleteAll callback function");
       return;
    }
 
    if (key == DELETED_KEY_VALUE) {
       table->deleted_key_data = NULL;
    } else {
-      entry = _mesa_hash_table_search(table->ht, uint_key(key));
+      uint32_t hash = uint_hash(key);
+      entry = _mesa_hash_table_search_pre_hashed(table->ht, hash,
+                                                 uint_key(key));
       _mesa_hash_table_remove(table->ht, entry);
    }
 }
 
 
 void
 _mesa_HashRemoveLocked(struct _mesa_HashTable *table, GLuint key)
 {
    _mesa_HashRemove_unlocked(table, key);
 }
-- 
2.9.3



More information about the mesa-dev mailing list