util/hash_table: add _mesa_hash_table_num_entries
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 11 Jan 2016 20:07:27 +0000 (15:07 -0500)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 3 Feb 2016 13:03:35 +0000 (14:03 +0100)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/main/hash.c
src/util/hash_table.h

index 315b5d64004b80656640ce096e3ccfc88241848a..ab1b9e907ae5af5b8386b5361437551c3599ec00 100644 (file)
@@ -496,14 +496,12 @@ _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys)
 GLuint
 _mesa_HashNumEntries(const struct _mesa_HashTable *table)
 {
-   struct hash_entry *entry;
    GLuint count = 0;
 
    if (table->deleted_key_data)
       count++;
 
-   hash_table_foreach(table->ht, entry)
-      count++;
+   count += _mesa_hash_table_num_entries(table->ht);
 
    return count;
 }
index 611dcf810dca2431ea8de319b9e647b1e22e628d..85b013cac2482001943b319f90893958b84807f9 100644 (file)
@@ -69,6 +69,11 @@ void _mesa_hash_table_clear(struct hash_table *ht,
 void _mesa_hash_table_set_deleted_key(struct hash_table *ht,
                                       const void *deleted_key);
 
+static inline uint32_t _mesa_hash_table_num_entries(struct hash_table *ht)
+{
+   return ht->entries;
+}
+
 struct hash_entry *
 _mesa_hash_table_insert(struct hash_table *ht, const void *key, void *data);
 struct hash_entry *