Skip to content

Commit 488dbfa

Browse files
authored
fix deadlock in shrink_to_fit (#305)
1 parent 458238c commit 488dbfa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,9 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: 'a + BuildHasher + Clone> Map<'a, K, V, S>
11101110

11111111
fn _shrink_to_fit(&self) {
11121112
self.shards.iter().for_each(|s| {
1113-
s.write().shrink_to(self.len(), |(k, _v)| {
1113+
let mut shard = s.write();
1114+
let size = shard.len();
1115+
shard.shrink_to(size, |(k, _v)| {
11141116
let mut hasher = self.hasher.build_hasher();
11151117
k.hash(&mut hasher);
11161118
hasher.finish()

0 commit comments

Comments
 (0)