Skip to content

Commit

Permalink
Add check for if a shard_amount is a power of two. (#186)
Browse files Browse the repository at this point in the history
Signed-off-by: Leo Lu <[email protected]>
  • Loading branch information
leoleoasd authored Mar 1, 2022
1 parent 6321c88 commit 23f3d04
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S> {
shard_amount: usize,
) -> Self {
assert!(shard_amount > 0);
assert!(shard_amount.is_power_of_two());

let shift = util::ptr_size_bits() - ncb(shard_amount);

Expand Down

0 comments on commit 23f3d04

Please sign in to comment.