From 083efe6361d3f3cbd6a91cd4ebffc59fbeff18fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 29 Sep 2022 21:52:42 +0200 Subject: [PATCH] astutils.h: use pre-sized SmallVector in visitAstNodes() (#3919) --- lib/astutils.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/astutils.h b/lib/astutils.h index 18fe9dc4e..f3923f8b6 100644 --- a/lib/astutils.h +++ b/lib/astutils.h @@ -56,11 +56,9 @@ void visitAstNodes(T *ast, const TFunc &visitor) if (!ast) return; - std::vector tokensContainer; // the size of 8 was determined in tests to be sufficient to avoid excess allocations. also add 1 as a buffer. // we might need to increase that value in the future. - tokensContainer.reserve(8 + 1); - std::stack> tokens(std::move(tokensContainer)); + std::stack> tokens; T *tok = ast; do { ChildrenToVisit c = visitor(tok);