From: Gunnar Beutner Date: Fri, 26 Aug 2016 16:11:56 +0000 (+0200) Subject: Avoid unnecessary string copies for LiteralExpression objects X-Git-Tag: v2.6.0~206 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7194b36d3e0c35aa4650b2f14aec44e668ec897a;p=icinga2 Avoid unnecessary string copies for LiteralExpression objects refs #12509 --- 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;