From b606399095cc5357a93f40fb0d695eab8530bc98 Mon Sep 17 00:00:00 2001 From: Simon Vandel Sillesen Date: Sat, 16 May 2020 18:24:17 +0200 Subject: Reduce reallocations in ra_tt::buffer::TokenBuffer::new_inner --- crates/ra_tt/src/buffer.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ra_tt/src/buffer.rs b/crates/ra_tt/src/buffer.rs index 14b3f707d..5967f44cd 100644 --- a/crates/ra_tt/src/buffer.rs +++ b/crates/ra_tt/src/buffer.rs @@ -42,7 +42,9 @@ impl<'t> TokenBuffer<'t> { buffers: &mut Vec]>>, next: Option, ) -> 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() { -- cgit v1.2.3