mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 21:10:12 +01:00
compiler/types: Make key in subroutine_name more effective
Use the string itself as a key for searching -- and the internal allocated name as a key when storing. Because record_key_hash doesn't consider the name field, which is the only used field for a SUBROUTINE type, the hash key was always the same for all types. Using the name fixes this. Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23277>
This commit is contained in:
parent
d57eedefa9
commit
0f54621564
1 changed files with 4 additions and 6 deletions
|
|
@ -1527,22 +1527,20 @@ glsl_type::get_interface_instance(const glsl_struct_field *fields,
|
|||
const glsl_type *
|
||||
glsl_type::get_subroutine_instance(const char *subroutine_name)
|
||||
{
|
||||
const glsl_type key(subroutine_name);
|
||||
|
||||
simple_mtx_lock(&glsl_type::hash_mutex);
|
||||
assert(glsl_type_users > 0);
|
||||
|
||||
if (subroutine_types == NULL) {
|
||||
subroutine_types = _mesa_hash_table_create(NULL, record_key_hash,
|
||||
record_key_compare);
|
||||
subroutine_types = _mesa_hash_table_create(NULL, _mesa_hash_string,
|
||||
_mesa_key_string_equal);
|
||||
}
|
||||
|
||||
const struct hash_entry *entry = _mesa_hash_table_search(subroutine_types,
|
||||
&key);
|
||||
subroutine_name);
|
||||
if (entry == NULL) {
|
||||
const glsl_type *t = new glsl_type(subroutine_name);
|
||||
|
||||
entry = _mesa_hash_table_insert(subroutine_types, t, (void *) t);
|
||||
entry = _mesa_hash_table_insert(subroutine_types, t->name, (void *) t);
|
||||
}
|
||||
|
||||
assert(((glsl_type *) entry->data)->base_type == GLSL_TYPE_SUBROUTINE);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue