Skip to content

Commit ed154c6

Browse files
author
Julian LALU
committed
Improve hashmap
1 parent 6a53026 commit ed154c6

2 files changed

Lines changed: 676 additions & 12 deletions

File tree

interface/core/containers/hashset.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,17 +1340,17 @@ namespace hud
13401340
// If we have elements to copy, copy them
13411341
if (count_ > 0)
13421342
{
1343-
// auto compute_hash = [](const auto *slot) noexcept
1344-
// {
1345-
// if constexpr (hud::is_same_v<key_type, typename u_storage_t::key_type>)
1346-
// {
1347-
// return hasher_type {}(slot->key());
1348-
// }
1349-
// else
1350-
// {
1351-
// return hasher_type {}(slot->key());
1352-
// }
1353-
// };
1343+
auto compute_hash = [](const auto *slot) noexcept
1344+
{
1345+
if constexpr (hud::is_same_v<key_type, typename u_storage_t::key_type>)
1346+
{
1347+
return hasher_type {}(slot->key());
1348+
}
1349+
else
1350+
{
1351+
return hasher_type {}(static_cast<key_type>(slot->key()));
1352+
}
1353+
};
13541354

13551355
// if constexpr (hud::is_same_v<key_type, typename u_storage_t::key_type>)
13561356
// {
@@ -1359,7 +1359,7 @@ namespace hud
13591359
while (control_full_or_sentinel != other.control_ptr_sentinel())
13601360
{
13611361

1362-
u64 hash {hasher_type {}(static_cast<const key_type &>(slot_full_or_sentinel->key()))};
1362+
u64 hash {compute_hash(slot_full_or_sentinel)};
13631363
// Find H1 slot index
13641364
u64 h1 {H1(hash)};
13651365
usize slot_index {find_first_empty_or_deleted(control_ptr_, max_slot_count_, h1)};

0 commit comments

Comments
 (0)