perf(parser): Vec::with_capacity for great improvements

Also played around with SmallVec, it is actually perfoming worse in most
cases, and "equal" at best.

Signed-off-by: Charlotte Meyer <dev@buffet.sh>
This commit is contained in:
buffet 2022-11-07 21:48:44 +00:00
parent cfd15122ab
commit 009947fa29

View file

@ -29,7 +29,7 @@ impl<'a> From<&'a str> for ParseTree {
}
fn build_tree(parser: &mut Parser) -> Vec<ParseTree> {
let mut children = vec![];
let mut children = Vec::with_capacity(4);
while let Some(ev) = parser.next() {
match ev {