glsl/types: Use _mesa_hash_data for hashing function types
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 13 Jul 2016 21:26:50 +0000 (14:26 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 14 Jul 2016 17:48:25 +0000 (10:48 -0700)
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@jlekstrand.net>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
src/compiler/glsl_types.cpp

index fa271350f5bb43eb6a7d8a01024bc97970c5f854..e9b58dde43a7b8f43131d5090d349b364e346ee5 100644 (file)
@@ -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 *