From 7194b36d3e0c35aa4650b2f14aec44e668ec897a Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 26 Aug 2016 18:11:56 +0200 Subject: [PATCH] Avoid unnecessary string copies for LiteralExpression objects refs #12509 --- lib/config/expression.cpp | 3 +-- lib/config/expression.hpp | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/config/expression.cpp b/lib/config/expression.cpp index f9241da3a..41235476f 100644 --- a/lib/config/expression.cpp +++ b/lib/config/expression.cpp @@ -707,9 +707,8 @@ void icinga::BindToScope(Expression *& expr, ScopeSpecifier scopeSpec) } LiteralExpression *lexpr = dynamic_cast(expr); - ScriptFrame frame; - if (lexpr && lexpr->Evaluate(frame).GetValue().IsString()) { + if (lexpr && lexpr->GetValue().IsString()) { Expression *scope = new GetScopeExpression(scopeSpec); expr = new IndexerExpression(scope, lexpr, lexpr->GetDebugInfo()); } diff --git a/lib/config/expression.hpp b/lib/config/expression.hpp index 3734d7183..5c35c2ad7 100644 --- a/lib/config/expression.hpp +++ b/lib/config/expression.hpp @@ -239,6 +239,11 @@ class I2_CONFIG_API LiteralExpression : public Expression public: LiteralExpression(const Value& value = Value()); + const Value& GetValue(void) const + { + return m_Value; + } + protected: virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override; -- 2.40.0