diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_arena/src/map.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/ra_arena/src/map.rs b/crates/ra_arena/src/map.rs index 5e764113d..b9521c342 100644 --- a/crates/ra_arena/src/map.rs +++ b/crates/ra_arena/src/map.rs | |||
@@ -17,11 +17,9 @@ impl<T, V> ArenaMap<Idx<T>, V> { | |||
17 | if self.v.capacity() <= idx { | 17 | if self.v.capacity() <= idx { |
18 | self.v.reserve(idx + 1 - self.v.capacity()); | 18 | self.v.reserve(idx + 1 - self.v.capacity()); |
19 | } | 19 | } |
20 | if self.v.len() <= idx { | 20 | |
21 | while self.v.len() <= idx { | 21 | let fill = (idx + 1).saturating_sub(self.v.len()); |
22 | self.v.push(None); | 22 | self.v.extend(std::iter::repeat_with(|| None).take(fill)); |
23 | } | ||
24 | } | ||
25 | self.v[idx] = Some(t); | 23 | self.v[idx] = Some(t); |
26 | } | 24 | } |
27 | 25 | ||