From 87b0be9b6f60b28bc9b5af0800bc8ad38ec07b67 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Fri, 23 Apr 2021 22:48:52 -0400 Subject: [PATCH] performance: Pre-emptively reserve size of the values vector Each token will add a corresponding Variant into the vector, so we can avoid the performance penalty connected with dynamic resizes of the vector. --- src/Eval.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Eval.cpp b/src/Eval.cpp index e96464576..97f0c5ad8 100644 --- a/src/Eval.cpp +++ b/src/Eval.cpp @@ -224,6 +224,8 @@ void Eval::evaluatePostfixStack ( // This is stack used by the postfix evaluator. std::vector values; + values.reserve(tokens.size()); + for (const auto& token : tokens) { // Unary operators.