[icinga-checkins] icinga.org: icinga2/master: Avoid unnecessary string copies for LiteralExpression objects

git at icinga.org git at icinga.org
Fri Aug 26 18:12:39 CEST 2016


Module: icinga2
Branch: master
Commit: 7194b36d3e0c35aa4650b2f14aec44e668ec897a
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=7194b36d3e0c35aa4650b2f14aec44e668ec897a

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Fri Aug 26 18:11:56 2016 +0200

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 f9241da..4123547 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<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());
 	}
diff --git a/lib/config/expression.hpp b/lib/config/expression.hpp
index 3734d71..5c35c2a 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;
 



More information about the icinga-checkins mailing list