Skip to content

Commit 7ca5ef6

Browse files
committed
Use resize_with
1 parent f633f69 commit 7ca5ef6

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

crates/ra_arena/src/map.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ impl<T, V> ArenaMap<Idx<T>, V> {
1515
pub fn insert(&mut self, id: Idx<T>, t: V) {
1616
let idx = Self::to_idx(id);
1717

18-
let fill = (idx + 1).saturating_sub(self.v.len());
19-
self.v.extend(std::iter::repeat_with(|| None).take(fill));
18+
self.v.resize_with((idx + 1).max(self.v.len()), || None);
2019
self.v[idx] = Some(t);
2120
}
2221

0 commit comments

Comments
 (0)