Skip to content

Commit

Permalink
fix compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrtgs committed Aug 27, 2024
1 parent 8a798a6 commit 0933449
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ impl<K: Eq + Hash + Clone, V: Clone, S: Clone> Clone for DashMap<K, V, S> {

for shard in self.shards.iter() {
let shard = shard.read();

inner_shards.push(CachePadded::new(RwLock::new((*shard).clone())));
}

Expand Down Expand Up @@ -282,8 +281,11 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S> {

let cps = capacity / shard_amount;

let shards = vec![CachePadded::new(RwLock::new(HashMap::with_capacity(cps))); shard_amount]
.into_boxed_slice();
let shards = {
let mut shards = Vec::with_capacity(shard_amount);
shards.resize_with(shard_amount, || CachePadded::new(RwLock::new(HashMap::with_capacity(cps))));
shards.into_boxed_slice()
};

Self {
shift,
Expand Down

0 comments on commit 0933449

Please sign in to comment.