]> granicus.if.org Git - icinga2/commitdiff
Avoid unnecessary allocations in the FunctionCallExpression class 5819/head
authorGunnar Beutner <gunnar.beutner@icinga.com>
Wed, 29 Nov 2017 13:11:09 +0000 (14:11 +0100)
committerGunnar Beutner <gunnar.beutner@icinga.com>
Wed, 29 Nov 2017 13:11:09 +0000 (14:11 +0100)
lib/config/expression.cpp

index 3f95435a01cc2d76aa8f58aece286b06928566b9..a2a75f62f731a39656a7b0ef84b39819d1811bfe 100644 (file)
@@ -428,6 +428,7 @@ ExpressionResult FunctionCallExpression::DoEvaluate(ScriptFrame& frame, DebugHin
 
        if (vfunc.IsObjectType<Type>()) {
                std::vector<Value> arguments;
+               arguments.reserve(m_Args.size());
                for (Expression *arg : m_Args) {
                        ExpressionResult argres = arg->Evaluate(frame);
                        CHECK_RESULT(argres);
@@ -447,6 +448,7 @@ ExpressionResult FunctionCallExpression::DoEvaluate(ScriptFrame& frame, DebugHin
                BOOST_THROW_EXCEPTION(ScriptError("Function is not marked as safe for sandbox mode.", m_DebugInfo));
 
        std::vector<Value> arguments;
+       arguments.reserve(m_Args.size());
        for (Expression *arg : m_Args) {
                ExpressionResult argres = arg->Evaluate(frame);
                CHECK_RESULT(argres);