hashmap: use ternary op to shorten code
This commit is contained in:
parent
7f09920585
commit
70b400d9c2
|
@ -65,7 +65,7 @@ int trivial_compare_func(const void *a, const void *b) {
|
|||
|
||||
const struct hash_ops trivial_hash_ops = {
|
||||
.hash = trivial_hash_func,
|
||||
.compare = trivial_compare_func
|
||||
.compare = trivial_compare_func,
|
||||
};
|
||||
|
||||
void uint64_hash_func(const uint64_t *p, struct siphash *state) {
|
||||
|
|
|
@ -779,7 +779,7 @@ static struct HashmapBase *hashmap_base_new(const struct hash_ops *hash_ops, enu
|
|||
|
||||
h->type = type;
|
||||
h->from_pool = up;
|
||||
h->hash_ops = hash_ops ? hash_ops : &trivial_hash_ops;
|
||||
h->hash_ops = hash_ops ?: &trivial_hash_ops;
|
||||
|
||||
if (type == HASHMAP_TYPE_ORDERED) {
|
||||
OrderedHashmap *lh = (OrderedHashmap*)h;
|
||||
|
|
Loading…
Reference in New Issue