diff options
author | Simon Vandel Sillesen <[email protected]> | 2020-05-16 17:24:17 +0100 |
---|---|---|
committer | Simon Vandel Sillesen <[email protected]> | 2020-05-16 21:20:44 +0100 |
commit | b606399095cc5357a93f40fb0d695eab8530bc98 (patch) | |
tree | a0e341d8c1f40e6786b578116328135d29911264 | |
parent | ef6d53521f07caa9c524749116d5fe53e1e8408d (diff) |
Reduce reallocations in ra_tt::buffer::TokenBuffer::new_inner
-rw-r--r-- | crates/ra_tt/src/buffer.rs | 4 |
1 files changed, 3 insertions, 1 deletions
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> { | |||
42 | buffers: &mut Vec<Box<[Entry<'t>]>>, | 42 | buffers: &mut Vec<Box<[Entry<'t>]>>, |
43 | next: Option<EntryPtr>, | 43 | next: Option<EntryPtr>, |
44 | ) -> usize { | 44 | ) -> usize { |
45 | let mut entries = vec![]; | 45 | // Must contain everything in tokens and then the Entry::End |
46 | let start_capacity = tokens.len() + 1; | ||
47 | let mut entries = Vec::with_capacity(start_capacity); | ||
46 | let mut children = vec![]; | 48 | let mut children = vec![]; |
47 | 49 | ||
48 | for (idx, tt) in tokens.iter().enumerate() { | 50 | for (idx, tt) in tokens.iter().enumerate() { |