[Mesa-dev] [PATCH 2/2] mesa: Use the new hash table for the variable refcount visitor.
Eric Anholt
eric at anholt.net
Tue Dec 4 10:41:01 PST 2012
Ian Romanick <idr at freedesktop.org> writes:
> On 12/03/2012 02:52 PM, Jordan Justen wrote:
>> +static bool
>> +pointer_key_compare(const void *a, const void *b)
>> +{
>> + return a == b;
>> +}
>> +
>> +/* We could do better. */
>> +static uint32_t
>> +pointer_hash(void *a)
>> +{
>> + return (uintptr_t)a;
>
> Perhaps...
>
> return (uintptr_t) a / sizeof(ir_variable);
>
> Or at least shift of the low couple bits. Otherwise we know a lot of
> bins will be empty, right? (Or is this not that kind of hash table?)
It's prime-sized.
>> static bool debug = false;
>>
>> @@ -49,8 +50,11 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned)
>>
>> v.run(instructions);
>>
>> - foreach_iter(exec_list_iterator, iter, v.variable_list) {
>> - ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)iter.get();
>> + struct hash_entry *e;
>> + for (e = _mesa_hash_table_next_entry(v.ht, NULL);
>> + e != NULL;
>> + e = _mesa_hash_table_next_entry(v.ht, e)) {
>> + ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)e->data;
This should use the foreach macro.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20121204/5afffa6a/attachment.pgp>
More information about the mesa-dev
mailing list