Mesa (master): mesa: make _mesa_HashTable InDeleteAll debug only

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 1 19:35:11 UTC 2021


Module: Mesa
Branch: master
Commit: 43e243762f708d628157e3d073e28315cb21f601
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=43e243762f708d628157e3d073e28315cb21f601

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Wed Mar 10 11:20:37 2021 +0100

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 at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9533>

---

 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);



More information about the mesa-commit mailing list