util/hash_table: Rework the API to know about hashing
authorJason Ekstrand <jason@jlekstrand.net>
Tue, 25 Nov 2014 06:19:50 +0000 (22:19 -0800)
committerEric Anholt <eric@anholt.net>
Mon, 15 Dec 2014 03:32:53 +0000 (19:32 -0800)
commit94303a0750f9eaae3fcf598b7bf1320e521898fb
tree34bd7bea6b61d60c94731333e31ffdca21205a29
parent0d7f4c8658e00d30a1b0c3f2d803378eaa0717c7
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 <jason.ekstrand@intel.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
16 files changed:
src/gallium/drivers/vc4/vc4_opt_cse.c
src/glsl/ir_variable_refcount.cpp
src/glsl/link_uniform_block_active_visitor.cpp
src/glsl/link_uniform_blocks.cpp
src/mesa/main/hash.c
src/util/hash_table.c
src/util/hash_table.h
src/util/tests/hash_table/collision.c
src/util/tests/hash_table/delete_and_lookup.c
src/util/tests/hash_table/delete_management.c
src/util/tests/hash_table/destroy_callback.c
src/util/tests/hash_table/insert_and_lookup.c
src/util/tests/hash_table/insert_many.c
src/util/tests/hash_table/random_entry.c
src/util/tests/hash_table/remove_null.c
src/util/tests/hash_table/replacement.c