mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +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> {
|
impl<T, V> ArenaMap<Idx<T>, V> {
|
||||||
pub fn insert(&mut self, id: Idx<T>, t: V) {
|
pub fn insert(&mut self, id: Idx<T>, t: V) {
|
||||||
let idx = Self::to_idx(id);
|
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());
|
let fill = (idx + 1).saturating_sub(self.v.len());
|
||||||
self.v.extend(std::iter::repeat_with(|| None).take(fill));
|
self.v.extend(std::iter::repeat_with(|| None).take(fill));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue