mirror of https://github.com/xacrimon/dashmap
Add check for if a shard_amount is a power of two. (#186)
Signed-off-by: Leo Lu <luyuxuanleo@gmail.com>
This commit is contained in:
parent
6321c886b4
commit
23f3d04335
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue