mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
AK: Rename double_hash to rehash_for_collision
The name is currently quite confusing as it indicates it hashes doubles.
This commit is contained in:
parent
dbc04bbf1b
commit
4f5353cbb8
Notes:
sideshowbarker
2024-07-17 18:06:52 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/4f5353cbb8 Pull-request: https://github.com/SerenityOS/serenity/pull/17111 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/bgianfo ✅
3 changed files with 8 additions and 8 deletions
|
@ -19,7 +19,7 @@ constexpr unsigned int_hash(u32 key)
|
|||
return key;
|
||||
}
|
||||
|
||||
constexpr unsigned double_hash(u32 key)
|
||||
constexpr unsigned rehash_for_collision(u32 key)
|
||||
{
|
||||
unsigned const magic = 0xBA5EDB01;
|
||||
if (key == magic)
|
||||
|
|
|
@ -594,7 +594,7 @@ private:
|
|||
}
|
||||
} else if (target_bucket->state == BucketState::Rehashed) {
|
||||
// If the target bucket is already re-hashed, we do normal probing.
|
||||
target_hash = double_hash(target_hash);
|
||||
target_hash = rehash_for_collision(target_hash);
|
||||
target_bucket = &m_buckets[target_hash % m_capacity];
|
||||
} else {
|
||||
VERIFY(target_bucket->state != BucketState::End);
|
||||
|
@ -676,7 +676,7 @@ private:
|
|||
if (bucket.state != BucketState::Used && bucket.state != BucketState::Deleted)
|
||||
return nullptr;
|
||||
|
||||
hash = double_hash(hash);
|
||||
hash = rehash_for_collision(hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -703,7 +703,7 @@ private:
|
|||
return const_cast<BucketType*>(first_empty_bucket);
|
||||
}
|
||||
|
||||
hash = double_hash(hash);
|
||||
hash = rehash_for_collision(hash);
|
||||
}
|
||||
}
|
||||
[[nodiscard]] BucketType& lookup_for_writing(T const& value)
|
||||
|
|
|
@ -15,11 +15,11 @@ TEST_CASE(int_hash)
|
|||
static_assert(int_hash(0) == 1177991625u);
|
||||
}
|
||||
|
||||
TEST_CASE(double_hash)
|
||||
TEST_CASE(rehash_for_collision)
|
||||
{
|
||||
static_assert(double_hash(666) == 171644115u);
|
||||
static_assert(double_hash(0) == 1189591134u);
|
||||
static_assert(double_hash(0xBA5EDB01) == 0u);
|
||||
static_assert(rehash_for_collision(666) == 171644115u);
|
||||
static_assert(rehash_for_collision(0) == 1189591134u);
|
||||
static_assert(rehash_for_collision(0xBA5EDB01) == 0u);
|
||||
}
|
||||
|
||||
TEST_CASE(pair_int_hash)
|
||||
|
|
Loading…
Reference in a new issue