cso: inline a few frequently-used functions
authorMarek Olšák <marek.olsak@amd.com>
Sat, 10 Jun 2017 23:08:37 +0000 (01:08 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 21 Jun 2017 23:51:02 +0000 (01:51 +0200)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/auxiliary/cso_cache/cso_hash.c
src/gallium/auxiliary/cso_cache/cso_hash.h

index 2a3f3611e650d15d862a0561b689c6a88812de57..4d3e261a741f24a96d295d881383923018becb3c 100644 (file)
@@ -73,12 +73,6 @@ static int countBits(int hint)
    return numBits;
 }
 
-struct cso_node {
-   struct cso_node *next;
-   unsigned key;
-   void *value;
-};
-
 struct cso_hash_data {
    struct cso_node *fakeNext;
    struct cso_node **buckets;
@@ -89,13 +83,6 @@ struct cso_hash_data {
    int numBuckets;
 };
 
-struct cso_hash {
-   union {
-      struct cso_hash_data *d;
-      struct cso_node      *e;
-   } data;
-};
-
 static void *cso_data_allocate_node(struct cso_hash_data *hash)
 {
    return MALLOC(hash->nodeSize);
@@ -293,13 +280,6 @@ unsigned cso_hash_iter_key(struct cso_hash_iter iter)
    return iter.node->key;
 }
 
-void * cso_hash_iter_data(struct cso_hash_iter iter)
-{
-   if (!iter.node || iter.hash->data.e == iter.node)
-      return 0;
-   return iter.node->value;
-}
-
 static struct cso_node *cso_hash_data_next(struct cso_node *node)
 {
    union {
@@ -374,13 +354,6 @@ struct cso_hash_iter cso_hash_iter_next(struct cso_hash_iter iter)
    return next;
 }
 
-int cso_hash_iter_is_null(struct cso_hash_iter iter)
-{
-   if (!iter.node || iter.node == iter.hash->data.e)
-      return 1;
-   return 0;
-}
-
 void * cso_hash_take(struct cso_hash *hash,
                       unsigned akey)
 {
index e58981c364bed62f17cee528a965cf4acd7a2a1d..d6eeb04f1ac8e3e966b8cfa80c855ed4e5733043 100644 (file)
@@ -51,9 +51,18 @@ extern "C" {
 #endif
 
 
-struct cso_hash;
-struct cso_node;
+struct cso_node {
+   struct cso_node *next;
+   unsigned key;
+   void *value;
+};
 
+struct cso_hash {
+   union {
+      struct cso_hash_data *d;
+      struct cso_node      *e;
+   } data;
+};
 
 struct cso_hash_iter {
    struct cso_hash *hash;
@@ -102,9 +111,7 @@ struct cso_hash_iter cso_hash_find(struct cso_hash *hash, unsigned key);
 boolean   cso_hash_contains(struct cso_hash *hash, unsigned key);
 
 
-int       cso_hash_iter_is_null(struct cso_hash_iter iter);
 unsigned  cso_hash_iter_key(struct cso_hash_iter iter);
-void     *cso_hash_iter_data(struct cso_hash_iter iter);
 
 
 struct cso_hash_iter cso_hash_iter_next(struct cso_hash_iter iter);
@@ -121,6 +128,21 @@ void *cso_hash_find_data_from_template( struct cso_hash *hash,
                                        void *templ,
                                        int size );
 
+static inline int
+cso_hash_iter_is_null(struct cso_hash_iter iter)
+{
+   if (!iter.node || iter.node == iter.hash->data.e)
+      return 1;
+   return 0;
+}
+
+static inline void *
+cso_hash_iter_data(struct cso_hash_iter iter)
+{
+   if (!iter.node || iter.hash->data.e == iter.node)
+      return 0;
+   return iter.node->value;
+}
 
 #ifdef __cplusplus
 }