Reduce reallocations in ra_tt::buffer::TokenBuffer::new_inner

This commit is contained in:
Simon Vandel Sillesen 2020-05-16 18:24:17 +02:00
parent ef6d53521f
commit b606399095

View file

@ -42,7 +42,9 @@ impl<'t> TokenBuffer<'t> {
buffers: &mut Vec<Box<[Entry<'t>]>>,
next: Option<EntryPtr>,
) -> usize {
let mut entries = vec![];
// Must contain everything in tokens and then the Entry::End
let start_capacity = tokens.len() + 1;
let mut entries = Vec::with_capacity(start_capacity);
let mut children = vec![];
for (idx, tt) in tokens.iter().enumerate() {