Skip to content

Commit

Permalink
fix deadlock in shrink_to_fit (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
xacrimon authored Jun 24, 2024
1 parent 458238c commit 488dbfa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,9 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: 'a + BuildHasher + Clone> Map<'a, K, V, S>

fn _shrink_to_fit(&self) {
self.shards.iter().for_each(|s| {
s.write().shrink_to(self.len(), |(k, _v)| {
let mut shard = s.write();
let size = shard.len();
shard.shrink_to(size, |(k, _v)| {
let mut hasher = self.hasher.build_hasher();
k.hash(&mut hasher);
hasher.finish()
Expand Down

0 comments on commit 488dbfa

Please sign in to comment.