Skip to content

Commit 49c8d6f

Browse files
pre-allocate some capacity
1 parent 554453c commit 49c8d6f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

crates/djls-templates/src/parser.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ impl Parser {
1717
}
1818

1919
pub fn parse(&mut self) -> (Vec<Node>, Vec<ParseError>) {
20-
let mut nodelist = Vec::new();
21-
let mut errors = Vec::new();
20+
let mut nodelist = Vec::with_capacity(self.tokens.len() / 2);
21+
let mut errors = Vec::with_capacity(4);
2222

2323
while !self.is_at_end() {
2424
match self.next_node() {
@@ -93,6 +93,7 @@ impl Parser {
9393
for part in parts {
9494
bits.push(part.to_owned());
9595
}
96+
9697
let span = token.content_span_or_fallback();
9798

9899
Ok(Node::Tag { name, bits, span })

0 commit comments

Comments
 (0)