Mesa (master): gallium/cso_hash: inline a bunch of functions

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 14 23:52:33 UTC 2020


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Tue Jan 21 19:46:34 2020 -0500

gallium/cso_hash: inline a bunch of functions

I'm probably not getting anything out of this, but it's harmless.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3829>

---

 src/gallium/auxiliary/cso_cache/cso_hash.c | 41 +-----------------------
 src/gallium/auxiliary/cso_cache/cso_hash.h | 51 ++++++++++++++++++++++++++----
 2 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_hash.c b/src/gallium/auxiliary/cso_cache/cso_hash.c
index 4d3e261a741..9d633243ac9 100644
--- a/src/gallium/auxiliary/cso_cache/cso_hash.c
+++ b/src/gallium/auxiliary/cso_cache/cso_hash.c
@@ -73,16 +73,6 @@ static int countBits(int hint)
    return numBits;
 }
 
-struct cso_hash_data {
-   struct cso_node *fakeNext;
-   struct cso_node **buckets;
-   int size;
-   int nodeSize;
-   short userNumBits;
-   short numBits;
-   int numBuckets;
-};
-
 static void *cso_data_allocate_node(struct cso_hash_data *hash)
 {
    return MALLOC(hash->nodeSize);
@@ -189,21 +179,6 @@ static struct cso_node *cso_data_first_node(struct cso_hash_data *hash)
    return e;
 }
 
-static struct cso_node **cso_hash_find_node(struct cso_hash *hash, unsigned akey)
-{
-   struct cso_node **node;
-
-   if (hash->data.d->numBuckets) {
-      node = (struct cso_node **)(&hash->data.d->buckets[akey % hash->data.d->numBuckets]);
-      assert(*node == hash->data.e || (*node)->next);
-      while (*node != hash->data.e && (*node)->key != akey)
-         node = &(*node)->next;
-   } else {
-      node = (struct cso_node **)((const struct cso_node * const *)(&hash->data.e));
-   }
-   return node;
-}
-
 struct cso_hash_iter cso_hash_insert(struct cso_hash *hash,
                                        unsigned key, void *data)
 {
@@ -265,14 +240,6 @@ void cso_hash_delete(struct cso_hash *hash)
    FREE(hash);
 }
 
-struct cso_hash_iter cso_hash_find(struct cso_hash *hash,
-                                     unsigned key)
-{
-   struct cso_node **nextNode = cso_hash_find_node(hash, key);
-   struct cso_hash_iter iter = {hash, *nextNode};
-   return iter;
-}
-
 unsigned cso_hash_iter_key(struct cso_hash_iter iter)
 {
    if (!iter.node || iter.hash->data.e == iter.node)
@@ -280,7 +247,7 @@ unsigned cso_hash_iter_key(struct cso_hash_iter iter)
    return iter.node->key;
 }
 
-static struct cso_node *cso_hash_data_next(struct cso_node *node)
+struct cso_node *cso_hash_data_next(struct cso_node *node)
 {
    union {
       struct cso_node *next;
@@ -348,12 +315,6 @@ static struct cso_node *cso_hash_data_prev(struct cso_node *node)
    return a.e;
 }
 
-struct cso_hash_iter cso_hash_iter_next(struct cso_hash_iter iter)
-{
-   struct cso_hash_iter next = {iter.hash, cso_hash_data_next(iter.node)};
-   return next;
-}
-
 void * cso_hash_take(struct cso_hash *hash,
                       unsigned akey)
 {
diff --git a/src/gallium/auxiliary/cso_cache/cso_hash.h b/src/gallium/auxiliary/cso_cache/cso_hash.h
index d6eeb04f1ac..e41cb9e0af3 100644
--- a/src/gallium/auxiliary/cso_cache/cso_hash.h
+++ b/src/gallium/auxiliary/cso_cache/cso_hash.h
@@ -69,6 +69,15 @@ struct cso_hash_iter {
    struct cso_node  *node;
 };
 
+struct cso_hash_data {
+   struct cso_node *fakeNext;
+   struct cso_node **buckets;
+   int size;
+   int nodeSize;
+   short userNumBits;
+   short numBits;
+   int numBuckets;
+};
 
 struct cso_hash *cso_hash_create(void);
 void             cso_hash_delete(struct cso_hash *hash);
@@ -100,11 +109,6 @@ void  *cso_hash_take(struct cso_hash *hash, unsigned key);
 
 struct cso_hash_iter cso_hash_first_node(struct cso_hash *hash);
 
-/**
- * Return an iterator pointing to the first entry in the collision list.
- */
-struct cso_hash_iter cso_hash_find(struct cso_hash *hash, unsigned key);
-
 /**
  * Returns true if a value with the given key exists in the hash
  */
@@ -114,7 +118,6 @@ boolean   cso_hash_contains(struct cso_hash *hash, unsigned key);
 unsigned  cso_hash_iter_key(struct cso_hash_iter iter);
 
 
-struct cso_hash_iter cso_hash_iter_next(struct cso_hash_iter iter);
 struct cso_hash_iter cso_hash_iter_prev(struct cso_hash_iter iter);
 
 
@@ -128,6 +131,8 @@ void *cso_hash_find_data_from_template( struct cso_hash *hash,
 				        void *templ,
 				        int size );
 
+struct cso_node *cso_hash_data_next(struct cso_node *node);
+
 static inline int
 cso_hash_iter_is_null(struct cso_hash_iter iter)
 {
@@ -144,6 +149,40 @@ cso_hash_iter_data(struct cso_hash_iter iter)
    return iter.node->value;
 }
 
+static inline struct cso_node **
+cso_hash_find_node(struct cso_hash *hash, unsigned akey)
+{
+   struct cso_node **node;
+
+   if (hash->data.d->numBuckets) {
+      node = (struct cso_node **)(&hash->data.d->buckets[akey % hash->data.d->numBuckets]);
+      assert(*node == hash->data.e || (*node)->next);
+      while (*node != hash->data.e && (*node)->key != akey)
+         node = &(*node)->next;
+   } else {
+      node = (struct cso_node **)((const struct cso_node * const *)(&hash->data.e));
+   }
+   return node;
+}
+
+/**
+ * Return an iterator pointing to the first entry in the collision list.
+ */
+static inline struct cso_hash_iter
+cso_hash_find(struct cso_hash *hash, unsigned key)
+{
+   struct cso_node **nextNode = cso_hash_find_node(hash, key);
+   struct cso_hash_iter iter = {hash, *nextNode};
+   return iter;
+}
+
+static inline struct cso_hash_iter
+cso_hash_iter_next(struct cso_hash_iter iter)
+{
+   struct cso_hash_iter next = {iter.hash, cso_hash_data_next(iter.node)};
+   return next;
+}
+
 #ifdef	__cplusplus
 }
 #endif



More information about the mesa-commit mailing list