mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Do not call reserve since extend will handle it.
`Take` implements `TrustedLen` so we are guaranteed that only one reserve call will be made.
This commit is contained in:
parent
c39725212c
commit
f633f69e36
1 changed files with 0 additions and 3 deletions
|
@ -14,9 +14,6 @@ pub struct ArenaMap<ID, V> {
|
|||
impl<T, V> ArenaMap<Idx<T>, V> {
|
||||
pub fn insert(&mut self, id: Idx<T>, t: V) {
|
||||
let idx = Self::to_idx(id);
|
||||
if self.v.capacity() <= idx {
|
||||
self.v.reserve(idx + 1 - self.v.capacity());
|
||||
}
|
||||
|
||||
let fill = (idx + 1).saturating_sub(self.v.len());
|
||||
self.v.extend(std::iter::repeat_with(|| None).take(fill));
|
||||
|
|
Loading…
Reference in a new issue