[Mesa-dev] [PATCH 4/7] glsl: Prehash to avoid hashing two times when inserting

Thomas Helland thomashelland90 at gmail.com
Thu Feb 2 22:05:04 UTC 2017


2017-02-02 21:57 GMT+01:00 Thomas Helland <thomashelland90 at gmail.com>:
> ---
>  src/compiler/glsl/opt_constant_variable.cpp | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/glsl/opt_constant_variable.cpp b/src/compiler/glsl/opt_constant_variable.cpp
> index 1c06ffe675..a07d64067b 100644
> --- a/src/compiler/glsl/opt_constant_variable.cpp
> +++ b/src/compiler/glsl/opt_constant_variable.cpp
> @@ -62,7 +62,9 @@ public:
>  static struct assignment_entry *
>  get_assignment_entry(ir_variable *var, struct hash_table *ht)
>  {
> -   struct hash_entry *hte = _mesa_hash_table_search(ht, var);
> +   uint32_t hash = ht->key_hash_function(var);
> +   struct hash_entry *hte =

Darn. Trailing whitespace here. I'll send a V2.

> +         _mesa_hash_table_search_pre_hashed(ht, hash, var);
>     struct assignment_entry *entry;
>
>     if (hte) {
> @@ -70,7 +72,7 @@ get_assignment_entry(ir_variable *var, struct hash_table *ht)
>     } else {
>        entry = (struct assignment_entry *) calloc(1, sizeof(*entry));
>        entry->var = var;
> -      _mesa_hash_table_insert(ht, var, entry);
> +      _mesa_hash_table_insert_pre_hashed(ht, hash, var, entry);
>     }
>
>     return entry;
> --
> 2.11.0
>


More information about the mesa-dev mailing list