From 55fb921d691f6d2d9e1ab105adb63a61fea7dc50 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolai=20H=C3=A4hnle?= Date: Mon, 11 Jan 2016 15:07:27 -0500 Subject: [PATCH] util/hash_table: add _mesa_hash_table_num_entries MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák --- src/mesa/main/hash.c | 4 +--- src/util/hash_table.h | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index 315b5d64004..ab1b9e907ae 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -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; } diff --git a/src/util/hash_table.h b/src/util/hash_table.h index 611dcf810dc..85b013cac24 100644 --- a/src/util/hash_table.h +++ b/src/util/hash_table.h @@ -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 * -- 2.30.2