about summary refs log tree commit diff
diff options
context:
space:
mode:
authorinquisitivecrystal <22333129+inquisitivecrystal@users.noreply.github.com>2021-07-20 15:40:30 -0700
committerinquisitivecrystal <22333129+inquisitivecrystal@users.noreply.github.com>2021-07-20 15:56:36 -0700
commite7fe2dfef253c462699783e7b2b297827f7440a7 (patch)
tree78e1ea9a6b09cff6b1acbdfe8ca93fa2fe6c0792
parentc9aa2595d9ba2313bbfcc8e0244231baa9c5d9e0 (diff)
downloadrust-e7fe2dfef253c462699783e7b2b297827f7440a7.tar.gz
rust-e7fe2dfef253c462699783e7b2b297827f7440a7.zip
Use hashbrown's `extend_reserve()` in `HashMap`
-rw-r--r--library/std/src/collections/hash/map.rs10
1 files changed, 1 insertions, 9 deletions
diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs
index fac285c96f0..c07555c9101 100644
--- a/library/std/src/collections/hash/map.rs
+++ b/library/std/src/collections/hash/map.rs
@@ -2786,15 +2786,7 @@ where
 
     #[inline]
     fn extend_reserve(&mut self, additional: usize) {
-        // self.base.extend_reserve(additional);
-        // FIXME: hashbrown should implement this method.
-        // But until then, use the same reservation logic:
-
-        // Reserve the entire hint lower bound if the map is empty.
-        // Otherwise reserve half the hint (rounded up), so the map
-        // will only resize twice in the worst case.
-        let reserve = if self.is_empty() { additional } else { (additional + 1) / 2 };
-        self.base.reserve(reserve);
+        self.base.extend_reserve(additional);
     }
 }