mesa: make _mesa_HashTable InDeleteAll debug only

It's only used in asserts so we can wrap it inside

This makes the struct 32 bytes instead of 40 in release
builds.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9533>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2021-03-10 11:20:37 +01:00 committed by Marge Bot
parent e26f261c7e
commit 43e243762f
2 changed files with 10 additions and 2 deletions

View file

@ -265,10 +265,12 @@ _mesa_HashRemove_unlocked(struct _mesa_HashTable *table, GLuint key)
assert(table);
assert(key);
#ifndef NDEBUG
/* assert if _mesa_HashRemove illegally called from _mesa_HashDeleteAll
* callback function. Have to check this outside of mutex lock.
*/
assert(!table->InDeleteAll);
#endif
if (key == DELETED_KEY_VALUE) {
table->deleted_key_data = NULL;
@ -314,7 +316,9 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table,
{
assert(callback);
_mesa_HashLockMutex(table);
#ifndef NDEBUG
table->InDeleteAll = GL_TRUE;
#endif
hash_table_foreach(table->ht, entry) {
callback(entry->data, userData);
_mesa_hash_table_remove(table->ht, entry);
@ -323,12 +327,14 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table,
callback(table->deleted_key_data, userData);
table->deleted_key_data = NULL;
}
table->InDeleteAll = GL_FALSE;
if (table->id_alloc) {
util_idalloc_fini(table->id_alloc);
free(table->id_alloc);
init_name_reuse(table);
}
#ifndef NDEBUG
table->InDeleteAll = GL_FALSE;
#endif
table->MaxKey = 0;
_mesa_HashUnlockMutex(table);
}

View file

@ -105,12 +105,14 @@ struct _mesa_HashTable {
struct hash_table *ht;
GLuint MaxKey; /**< highest key inserted so far */
simple_mtx_t Mutex; /**< mutual exclusion lock */
GLboolean InDeleteAll; /**< Debug check */
/* Used when name reuse is enabled */
struct util_idalloc* id_alloc;
/** Value that would be in the table for DELETED_KEY_VALUE. */
void *deleted_key_data;
#ifndef NDEBUG
GLboolean InDeleteAll; /**< Debug check */
#endif
};
extern struct _mesa_HashTable *_mesa_NewHashTable(void);