From 009947fa294b8422724a0b49a297880dc332d31d Mon Sep 17 00:00:00 2001 From: Charlotte Meyer Date: Mon, 7 Nov 2022 21:48:44 +0000 Subject: [PATCH] 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 --- crates/oyster_parser/src/cst.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oyster_parser/src/cst.rs b/crates/oyster_parser/src/cst.rs index f2e045e..1a4cb96 100644 --- a/crates/oyster_parser/src/cst.rs +++ b/crates/oyster_parser/src/cst.rs @@ -29,7 +29,7 @@ impl<'a> From<&'a str> for ParseTree { } fn build_tree(parser: &mut Parser) -> Vec { - let mut children = vec![]; + let mut children = Vec::with_capacity(4); while let Some(ev) = parser.next() { match ev {