aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_arena/src
diff options
context:
space:
mode:
authorkjeremy <[email protected]>2020-03-30 22:09:21 +0100
committerkjeremy <[email protected]>2020-03-30 22:09:21 +0100
commitf633f69e36f0aee2cb77a3436b54aeca9aa0d10e (patch)
tree4c5de31e2bf98664afb753d918e46b878afe88d2 /crates/ra_arena/src
parentc39725212c332bdc0914ca17947c8251b3b1e006 (diff)
Do not call reserve since extend will handle it.
`Take` implements `TrustedLen` so we are guaranteed that only one reserve call will be made.
Diffstat (limited to 'crates/ra_arena/src')
-rw-r--r--crates/ra_arena/src/map.rs3
1 files changed, 0 insertions, 3 deletions
diff --git a/crates/ra_arena/src/map.rs b/crates/ra_arena/src/map.rs
index b9521c342..e4ddbad42 100644
--- a/crates/ra_arena/src/map.rs
+++ b/crates/ra_arena/src/map.rs
@@ -14,9 +14,6 @@ pub struct ArenaMap<ID, V> {
14impl<T, V> ArenaMap<Idx<T>, V> { 14impl<T, V> ArenaMap<Idx<T>, V> {
15 pub fn insert(&mut self, id: Idx<T>, t: V) { 15 pub fn insert(&mut self, id: Idx<T>, t: V) {
16 let idx = Self::to_idx(id); 16 let idx = Self::to_idx(id);
17 if self.v.capacity() <= idx {
18 self.v.reserve(idx + 1 - self.v.capacity());
19 }
20 17
21 let fill = (idx + 1).saturating_sub(self.v.len()); 18 let fill = (idx + 1).saturating_sub(self.v.len());
22 self.v.extend(std::iter::repeat_with(|| None).take(fill)); 19 self.v.extend(std::iter::repeat_with(|| None).take(fill));