Skip to content
  • Jason Ekstrand's avatar
    util/hash_table: Rework the API to know about hashing · 94303a07
    Jason Ekstrand authored
    
    
    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: default avatarJason Ekstrand <jason.ekstrand@intel.com>
    Signed-off-by: default avatarEric Anholt <eric@anholt.net>
    Reviewed-by: default avatarEric Anholt <eric@anholt.net>
    94303a07