[Mesa-dev] [PATCH 02/23] mesa: Replace hashing functions of prog_hash_table

Thomas Helland thomashelland90 at gmail.com
Tue Aug 16 20:10:15 UTC 2016


This will make it functionally equivalent to the one in util.
This enables us to do a step-by-step replacement of the table.

Signed-off-by: Thomas Helland <thomashelland90 at gmail.com>
---
 src/mesa/program/prog_hash_table.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/mesa/program/prog_hash_table.c b/src/mesa/program/prog_hash_table.c
index cbea74c..a712175 100644
--- a/src/mesa/program/prog_hash_table.c
+++ b/src/mesa/program/prog_hash_table.c
@@ -35,33 +35,27 @@
 unsigned
 hash_table_string_hash(const void *key)
 {
-    const char *str = (const char *) key;
-    unsigned hash = 5381;
-
-
-    while (*str != '\0') {
-        hash = (hash * 33) + *str;
-        str++;
-    }
-
-    return hash;
+   const char *str = (const char *) key;
+   uint32_t hash = _mesa_hash_string(str);
+   return hash;
 }
 
-bool hash_table_string_compare(const void *a, const void *b)
+bool
+hash_table_string_compare(const void *a, const void *b)
 {
-   return strcmp(a, b) == 0;
+   return _mesa_key_string_equal(a, b);
 }
 
 
 unsigned
 hash_table_pointer_hash(const void *key)
 {
-   return (unsigned)((uintptr_t) key / sizeof(void *));
+   return _mesa_hash_pointer(key);
 }
 
 
 bool
 hash_table_pointer_compare(const void *key1, const void *key2)
 {
-   return key1 == key2;
+   return _mesa_key_pointer_equal(key1, key2);
 }
-- 
2.9.2



More information about the mesa-dev mailing list