Mesa (master): glsl/types: Use _mesa_hash_data for hashing function types

Jason Ekstrand jekstrand at kemper.freedesktop.org
Thu Jul 14 17:48:45 UTC 2016


Module: Mesa
Branch: master
Commit: b919100d6101c0bd7e15a187968af9a36b49e6de
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b919100d6101c0bd7e15a187968af9a36b49e6de

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Wed Jul 13 14:26:50 2016 -0700

glsl/types: Use _mesa_hash_data for hashing function types

This is way better than the stupid string approach especially since you
could overflow the string.  Again, I thought I had something better at one
point but it obviously got lost.

Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Cc: "12.0" <mesa-stable at lists.freedesktop.org>

---

 src/compiler/glsl_types.cpp | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index fa27135..e9b58dd 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -1097,20 +1097,8 @@ static uint32_t
 function_key_hash(const void *a)
 {
    const glsl_type *const key = (glsl_type *) a;
-   char hash_key[128];
-   unsigned size = 0;
-
-   size = snprintf(hash_key, sizeof(hash_key), "%08x", key->length);
-
-   for (unsigned i = 0; i < key->length; i++) {
-      if (size >= sizeof(hash_key))
-	 break;
-
-      size += snprintf(& hash_key[size], sizeof(hash_key) - size,
-		       "%p", (void *) key->fields.structure[i].type);
-   }
-
-   return _mesa_hash_string(hash_key);
+   return _mesa_hash_data(key->fields.parameters,
+                          (key->length + 1) * sizeof(*key->fields.parameters));
 }
 
 const glsl_type *




More information about the mesa-commit mailing list