util/set: add the found param to search_or_add
this brings parity with the internal api Reviewed-by: Eric Anholt <eric@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8450>
This commit is contained in:
parent
5f3f128088
commit
491e7decad
|
@ -807,7 +807,7 @@ nir_instr_set_add_or_rewrite(struct set *instr_set, nir_instr *instr)
|
|||
if (!instr_can_rewrite(instr))
|
||||
return false;
|
||||
|
||||
struct set_entry *e = _mesa_set_search_or_add(instr_set, instr);
|
||||
struct set_entry *e = _mesa_set_search_or_add(instr_set, instr, NULL);
|
||||
nir_instr *match = (nir_instr *) e->key;
|
||||
if (match != instr) {
|
||||
nir_ssa_def *def = nir_instr_get_dest_ssa_def(instr);
|
||||
|
|
|
@ -510,15 +510,15 @@ _mesa_set_search_and_add_pre_hashed(struct set *set, uint32_t hash,
|
|||
}
|
||||
|
||||
struct set_entry *
|
||||
_mesa_set_search_or_add(struct set *set, const void *key)
|
||||
_mesa_set_search_or_add(struct set *set, const void *key, bool *found)
|
||||
{
|
||||
assert(set->key_hash_function);
|
||||
return set_search_or_add(set, set->key_hash_function(key), key, NULL);
|
||||
return set_search_or_add(set, set->key_hash_function(key), key, found);
|
||||
}
|
||||
|
||||
struct set_entry *
|
||||
_mesa_set_search_or_add_pre_hashed(struct set *set, uint32_t hash,
|
||||
const void *key)
|
||||
const void *key, bool *found)
|
||||
{
|
||||
assert(set->key_hash_function == NULL ||
|
||||
hash == set->key_hash_function(key));
|
||||
|
|
|
@ -81,10 +81,10 @@ struct set_entry *
|
|||
_mesa_set_add_pre_hashed(struct set *set, uint32_t hash, const void *key);
|
||||
|
||||
struct set_entry *
|
||||
_mesa_set_search_or_add(struct set *set, const void *key);
|
||||
_mesa_set_search_or_add(struct set *set, const void *key, bool *found);
|
||||
struct set_entry *
|
||||
_mesa_set_search_or_add_pre_hashed(struct set *set, uint32_t hash,
|
||||
const void *key);
|
||||
const void *key, bool *found);
|
||||
|
||||
struct set_entry *
|
||||
_mesa_set_search(const struct set *set, const void *key);
|
||||
|
|
|
@ -143,12 +143,16 @@ TEST(set, search_or_add)
|
|||
_mesa_set_add(s, &b);
|
||||
EXPECT_EQ(s->entries, 2);
|
||||
|
||||
struct set_entry *entry = _mesa_set_search_or_add(s, &c);
|
||||
bool found = false;
|
||||
struct set_entry *entry = _mesa_set_search_or_add(s, &c, &found);
|
||||
EXPECT_EQ(entry->key, (void *)&b);
|
||||
EXPECT_EQ(found, true);
|
||||
EXPECT_EQ(s->entries, 2);
|
||||
|
||||
struct set_entry *entry3 = _mesa_set_search_or_add(s, &d);
|
||||
found = false;
|
||||
struct set_entry *entry3 = _mesa_set_search_or_add(s, &d, &found);
|
||||
EXPECT_EQ(entry3->key, &d);
|
||||
EXPECT_EQ(found, false);
|
||||
EXPECT_EQ(s->entries, 3);
|
||||
|
||||
_mesa_set_destroy(s, NULL);
|
||||
|
|
Loading…
Reference in New Issue