assert that the shard count is not 1 (#273)

* assert that the shard count is not 1

* lint
This commit is contained in:
Joel 2023-07-11 05:39:27 +02:00 committed by GitHub
parent 6616a8d28c
commit 018f0a1671
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 4 deletions

View File

@ -270,7 +270,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S> {
hasher: S,
shard_amount: usize,
) -> Self {
assert!(shard_amount > 0);
assert!(shard_amount > 1);
assert!(shard_amount.is_power_of_two());
let shift = util::ptr_size_bits() - ncb(shard_amount);

View File

@ -159,9 +159,7 @@ impl<'a, K: Eq + Hash, V, S: BuildHasher> VacantEntry<'a, K, V, S> {
let kptr: *const K = k;
let vptr: *mut V = v.as_ptr();
let r = OccupiedEntry::new(self.shard, self.key, (kptr, vptr));
r
OccupiedEntry::new(self.shard, self.key, (kptr, vptr))
}
}