cso: inline a few frequently-used functions
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user