1
Fork 0

Reserve space in advance

This commit is contained in:
Dániel Buga 2020-10-16 11:43:39 +02:00
parent 2ca0b85593
commit a7f2bb6343
4 changed files with 9 additions and 7 deletions

View file

@ -221,7 +221,7 @@ impl TokenStream {
}
}
if let Some((pos, comma, sp)) = suggestion {
let mut new_stream = vec![];
let mut new_stream = Vec::with_capacity(self.0.len() + 1);
let parts = self.0.split_at(pos + 1);
new_stream.extend_from_slice(parts.0);
new_stream.push(comma);