From 43e243762f708d628157e3d073e28315cb21f601 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 10 Mar 2021 11:20:37 +0100 Subject: [PATCH] mesa: make _mesa_HashTable InDeleteAll debug only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Part-of: --- src/mesa/main/hash.c | 8 +++++++- src/mesa/main/hash.h | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index 2c3064ca673..8d2cef7c909 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -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); } diff --git a/src/mesa/main/hash.h b/src/mesa/main/hash.h index b476b1bce30..18612bd5c47 100644 --- a/src/mesa/main/hash.h +++ b/src/mesa/main/hash.h @@ -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);