Browse Source

hash_table: Rename insert_with_hash to insert_pre_hashed

We already have search_pre_hashed.  This makes the APIs match better.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
tags/10.5-branchpoint
Jason Ekstrand 10 years ago
parent
commit
8ed5305d28

+ 1
- 1
src/glsl/nir/nir_lower_locals_to_regs.c View File

@@ -118,7 +118,7 @@ get_reg_for_deref(nir_deref_var *deref, struct locals_to_regs_state *state)
reg->num_components = glsl_get_vector_elements(tail->type);
reg->num_array_elems = array_size > 1 ? array_size : 0;

_mesa_hash_table_insert_with_hash(state->regs_table, hash, deref, reg);
_mesa_hash_table_insert_pre_hashed(state->regs_table, hash, deref, reg);

return reg;
}

+ 1
- 1
src/mesa/main/hash.c View File

@@ -277,7 +277,7 @@ _mesa_HashInsert_unlocked(struct _mesa_HashTable *table, GLuint key, void *data)
if (entry) {
entry->data = data;
} else {
_mesa_hash_table_insert_with_hash(table->ht, hash, uint_key(key), data);
_mesa_hash_table_insert_pre_hashed(table->ht, hash, uint_key(key), data);
}
}
}

+ 2
- 2
src/util/hash_table.c View File

@@ -334,8 +334,8 @@ _mesa_hash_table_insert(struct hash_table *ht, const void *key, void *data)
}

struct hash_entry *
_mesa_hash_table_insert_with_hash(struct hash_table *ht, uint32_t hash,
const void *key, void *data)
_mesa_hash_table_insert_pre_hashed(struct hash_table *ht, uint32_t hash,
const void *key, void *data)
{
assert(ht->key_hash_function == NULL || hash == ht->key_hash_function(key));
return hash_table_insert(ht, hash, key, data);

+ 2
- 2
src/util/hash_table.h View File

@@ -70,8 +70,8 @@ void _mesa_hash_table_set_deleted_key(struct hash_table *ht,
struct hash_entry *
_mesa_hash_table_insert(struct hash_table *ht, const void *key, void *data);
struct hash_entry *
_mesa_hash_table_insert_with_hash(struct hash_table *ht, uint32_t hash,
const void *key, void *data);
_mesa_hash_table_insert_pre_hashed(struct hash_table *ht, uint32_t hash,
const void *key, void *data);
struct hash_entry *
_mesa_hash_table_search(struct hash_table *ht, const void *key);
struct hash_entry *

+ 4
- 4
src/util/tests/hash_table/collision.c View File

@@ -42,8 +42,8 @@ main(int argc, char **argv)

ht = _mesa_hash_table_create(NULL, NULL, _mesa_key_string_equal);

_mesa_hash_table_insert_with_hash(ht, bad_hash, str1, NULL);
_mesa_hash_table_insert_with_hash(ht, bad_hash, str2, NULL);
_mesa_hash_table_insert_pre_hashed(ht, bad_hash, str1, NULL);
_mesa_hash_table_insert_pre_hashed(ht, bad_hash, str2, NULL);

entry1 = _mesa_hash_table_search_pre_hashed(ht, bad_hash, str1);
assert(entry1->key == str1);
@@ -63,11 +63,11 @@ main(int argc, char **argv)
/* Put str1 back, then spam junk into the table to force a
* resize and make sure we can still find them both.
*/
_mesa_hash_table_insert_with_hash(ht, bad_hash, str1, NULL);
_mesa_hash_table_insert_pre_hashed(ht, bad_hash, str1, NULL);
for (i = 0; i < 100; i++) {
char *key = malloc(10);
sprintf(key, "spam%d", i);
_mesa_hash_table_insert_with_hash(ht, _mesa_hash_string(key), key, NULL);
_mesa_hash_table_insert_pre_hashed(ht, _mesa_hash_string(key), key, NULL);
}
entry1 = _mesa_hash_table_search_pre_hashed(ht, bad_hash, str1);
assert(entry1->key == str1);

Loading…
Cancel
Save