Skip to content

Commit

Permalink
Cosmetic fixes in hashmap
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv committed Oct 17, 2023
1 parent c082d25 commit de830bd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/internal_modules/roc_core/hashmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class Hashmap : public NonCopyable<> {
const hashsum_t hash = T::key_hash(key);
HashmapNode::HashmapNodeData* node = impl_.find_node(
hash, (const void*)&key,
&Hashmap<T, EmbeddedCapacity, OwnershipPolicy>::key_equals<Key>);
&Hashmap<T, EmbeddedCapacity, OwnershipPolicy>::key_equal<Key>);
if (!node) {
return NULL;
}
Expand Down Expand Up @@ -284,7 +284,7 @@ class Hashmap : public NonCopyable<> {
}

template <class Key>
static bool key_equals(HashmapNode::HashmapNodeData* node, const void* key) {
static bool key_equal(HashmapNode::HashmapNodeData* node, const void* key) {
T* elem = container_of_(node);
const Key& key_ref = *(const Key*)key;
return T::key_equal(elem->key(), key_ref);
Expand All @@ -294,7 +294,7 @@ class Hashmap : public NonCopyable<> {
void insert_(const Key& key, HashmapNode::HashmapNodeData* node) {
const hashsum_t hash = T::key_hash(key);
impl_.insert(node, hash, (const void*)&key,
&Hashmap<T, EmbeddedCapacity, OwnershipPolicy>::key_equals<Key>);
&Hashmap<T, EmbeddedCapacity, OwnershipPolicy>::key_equal<Key>);
}

AlignedStorage<NumEmbeddedBuckets * sizeof(HashmapImpl::Bucket)> embedded_buckets_;
Expand Down
5 changes: 4 additions & 1 deletion src/internal_modules/roc_core/hashmap_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ HashmapImpl::HashmapImpl(void* preallocated_data,
}

HashmapImpl::~HashmapImpl() {
if (size_ != 0) {
roc_panic("hashmap: hashmap isn't empty on destruct");
}
dealloc_buckets_();
}

Expand Down Expand Up @@ -146,7 +149,7 @@ void HashmapImpl::remove(HashmapNode::HashmapNodeData* node, bool skip_rehash) {
}
}

ROC_ATTR_NODISCARD bool HashmapImpl::grow() {
bool HashmapImpl::grow() {
const size_t cap = buckets_capacity_(n_curr_buckets_);
roc_panic_if_not(size_ <= cap);

Expand Down
7 changes: 3 additions & 4 deletions src/internal_modules/roc_core/hashmap_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ class HashmapImpl {
typedef bool (*key_equals_callback)(HashmapNode::HashmapNodeData* node,
const void* key);

//! Initialize empty hashmap with arena.
explicit HashmapImpl(void* preallocated_data,
size_t num_embedded_buckets,
IArena* arena);
//! Initialize empty hashmap.
HashmapImpl(void* preallocated_data, size_t num_embedded_buckets, IArena* arena);

//! Deinitialize.
~HashmapImpl();

//! Get maximum number of nodes that can be added to hashmap before
Expand Down

0 comments on commit de830bd

Please sign in to comment.