mesa: make _mesa_HashTable InDeleteAll debug only
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Wed, 10 Mar 2021 10:20:37 +0000 (11:20 +0100)
committerMarge Bot <eric+marge@anholt.net>
Thu, 1 Apr 2021 19:16:39 +0000 (19:16 +0000)
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>

src/mesa/main/hash.c
src/mesa/main/hash.h

index 2c3064c..8d2cef7 100644 (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);
 }
index b476b1b..18612bd 100644 (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);