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@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3829>
This commit is contained in:
parent
cf86f522b2
commit
f8594a06e4
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue