util/hash_table: Clean up the _mesa_hash_table_clear() implementation.

Use the entry_is_present() helper to clarify what's going on with
deletion, and then we can remove the special continue for NULL since we're
just writing NULL anyway (which the CPU cache will elide for us).

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7244>
This commit is contained in:
Eric Anholt
2020-10-20 15:04:27 -07:00
committed by Marge Bot
parent 9c5422c7dd
commit 4618ca82c3

View File

@@ -250,10 +250,7 @@ _mesa_hash_table_clear(struct hash_table *ht,
struct hash_entry *entry;
for (entry = ht->table; entry != ht->table + ht->size; entry++) {
if (entry->key == NULL)
continue;
if (delete_function != NULL && entry->key != ht->deleted_key)
if (entry_is_present(ht, entry) && delete_function != NULL)
delete_function(entry);
entry->key = NULL;