summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_variable_refcount.cpp
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2014-11-24 22:19:50 -0800
committerEric Anholt <[email protected]>2014-12-14 19:32:53 -0800
commit94303a0750f9eaae3fcf598b7bf1320e521898fb (patch)
tree34bd7bea6b61d60c94731333e31ffdca21205a29 /src/glsl/ir_variable_refcount.cpp
parent0d7f4c8658e00d30a1b0c3f2d803378eaa0717c7 (diff)
util/hash_table: Rework the API to know about hashing
Previously, the hash_table API required the user to do all of the hashing of keys as it passed them in. Since the hashing function is intrinsically tied to the comparison function, it makes sense for the hash table to know about it. Also, it makes for a somewhat clumsy API as the user is constantly calling hashing functions many of which have long names. This is especially bad when the standard call looks something like _mesa_hash_table_insert(ht, _mesa_pointer_hash(key), key, data); In the above case, there is no reason why the hash table shouldn't do the hashing for you. We leave the option for you to do your own hashing if it's more efficient, but it's no longer needed. Also, if you do do your own hashing, the hash table will assert that your hash matches what it expects out of the hashing function. This should make it harder to mess up your hashing. v2: change to call the old entrypoint "pre_hashed" rather than "with_hash", like cworth's equivalent change upstream (change by anholt, acked-in-general by Jason). Signed-off-by: Jason Ekstrand <[email protected]> Signed-off-by: Eric Anholt <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/glsl/ir_variable_refcount.cpp')
-rw-r--r--src/glsl/ir_variable_refcount.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/glsl/ir_variable_refcount.cpp b/src/glsl/ir_variable_refcount.cpp
index f67fe678443..e4d825c454b 100644
--- a/src/glsl/ir_variable_refcount.cpp
+++ b/src/glsl/ir_variable_refcount.cpp
@@ -38,7 +38,8 @@
ir_variable_refcount_visitor::ir_variable_refcount_visitor()
{
this->mem_ctx = ralloc_context(NULL);
- this->ht = _mesa_hash_table_create(NULL, _mesa_key_pointer_equal);
+ this->ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
+ _mesa_key_pointer_equal);
}
static void
@@ -70,15 +71,13 @@ ir_variable_refcount_visitor::get_variable_entry(ir_variable *var)
{
assert(var);
- struct hash_entry *e = _mesa_hash_table_search(this->ht,
- _mesa_hash_pointer(var),
- var);
+ struct hash_entry *e = _mesa_hash_table_search(this->ht, var);
if (e)
return (ir_variable_refcount_entry *)e->data;
ir_variable_refcount_entry *entry = new ir_variable_refcount_entry(var);
assert(entry->referenced_count == 0);
- _mesa_hash_table_insert(this->ht, _mesa_hash_pointer(var), var, entry);
+ _mesa_hash_table_insert(this->ht, var, entry);
return entry;
}