[Mesa-dev] [PATCH 4/6] glsl: Prehash in constant var pass to avoid hashing twice

Thomas Helland thomashelland90 at gmail.com
Mon May 22 18:55:43 UTC 2017


Should help us reduce some hash table overhead.

V2: Fix whitespace error
---
 src/compiler/glsl/opt_constant_variable.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/opt_constant_variable.cpp b/src/compiler/glsl/opt_constant_variable.cpp
index 1c06ffe675..430bf194a1 100644
--- a/src/compiler/glsl/opt_constant_variable.cpp
+++ b/src/compiler/glsl/opt_constant_variable.cpp
@@ -62,7 +62,9 @@ public:
 static struct assignment_entry *
 get_assignment_entry(ir_variable *var, struct hash_table *ht)
 {
-   struct hash_entry *hte = _mesa_hash_table_search(ht, var);
+   uint32_t hash = ht->key_hash_function(var);
+   struct hash_entry *hte =
+         _mesa_hash_table_search_pre_hashed(ht, hash, var);
    struct assignment_entry *entry;
 
    if (hte) {
@@ -70,7 +72,7 @@ get_assignment_entry(ir_variable *var, struct hash_table *ht)
    } else {
       entry = (struct assignment_entry *) calloc(1, sizeof(*entry));
       entry->var = var;
-      _mesa_hash_table_insert(ht, var, entry);
+      _mesa_hash_table_insert_pre_hashed(ht, hash, var, entry);
    }
 
    return entry;
-- 
2.13.0



More information about the mesa-dev mailing list