Skip to content

Commit e7fe2df

Browse files
Use hashbrown's extend_reserve() in HashMap
1 parent c9aa259 commit e7fe2df

File tree

1 file changed

+1
-9
lines changed
  • library/std/src/collections/hash

1 file changed

+1
-9
lines changed

library/std/src/collections/hash/map.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -2786,15 +2786,7 @@ where
27862786

27872787
#[inline]
27882788
fn extend_reserve(&mut self, additional: usize) {
2789-
// self.base.extend_reserve(additional);
2790-
// FIXME: hashbrown should implement this method.
2791-
// But until then, use the same reservation logic:
2792-
2793-
// Reserve the entire hint lower bound if the map is empty.
2794-
// Otherwise reserve half the hint (rounded up), so the map
2795-
// will only resize twice in the worst case.
2796-
let reserve = if self.is_empty() { additional } else { (additional + 1) / 2 };
2797-
self.base.reserve(reserve);
2789+
self.base.extend_reserve(additional);
27982790
}
27992791
}
28002792

0 commit comments

Comments
 (0)