Skip to content

Commit b606399

Browse files
committed
Reduce reallocations in ra_tt::buffer::TokenBuffer::new_inner
1 parent ef6d535 commit b606399

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

crates/ra_tt/src/buffer.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ impl<'t> TokenBuffer<'t> {
4242
buffers: &mut Vec<Box<[Entry<'t>]>>,
4343
next: Option<EntryPtr>,
4444
) -> 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);
4648
let mut children = vec![];
4749

4850
for (idx, tt) in tokens.iter().enumerate() {

0 commit comments

Comments
 (0)