]> granicus.if.org Git - icinga2/commitdiff
Avoid unnecessary string copies for LiteralExpression objects
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 26 Aug 2016 16:11:56 +0000 (18:11 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 26 Aug 2016 16:11:56 +0000 (18:11 +0200)
refs #12509

lib/config/expression.cpp
lib/config/expression.hpp

index f9241da3a7db64f99aa9fcda8de94b5cb3bf1a27..41235476f92ee3c74961bd9d21fce25abc9b79c2 100644 (file)
@@ -707,9 +707,8 @@ void icinga::BindToScope(Expression *& expr, ScopeSpecifier scopeSpec)
        }
 
        LiteralExpression *lexpr = dynamic_cast<LiteralExpression *>(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());
        }
index 3734d71832e4adabdafb6e25534c5eb87ce15ae3..5c35c2ad7b508e4cf93e0b801e505bcca2566f99 100644 (file)
@@ -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;