mirror of https://github.com/Icinga/icinga2.git
Avoid unnecessary string copies for LiteralExpression objects
refs #12509
This commit is contained in:
parent
c1a58446af
commit
7194b36d3e
|
@ -707,9 +707,8 @@ void icinga::BindToScope(Expression *& expr, ScopeSpecifier scopeSpec)
|
||||||
}
|
}
|
||||||
|
|
||||||
LiteralExpression *lexpr = dynamic_cast<LiteralExpression *>(expr);
|
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);
|
Expression *scope = new GetScopeExpression(scopeSpec);
|
||||||
expr = new IndexerExpression(scope, lexpr, lexpr->GetDebugInfo());
|
expr = new IndexerExpression(scope, lexpr, lexpr->GetDebugInfo());
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,6 +239,11 @@ class I2_CONFIG_API LiteralExpression : public Expression
|
||||||
public:
|
public:
|
||||||
LiteralExpression(const Value& value = Value());
|
LiteralExpression(const Value& value = Value());
|
||||||
|
|
||||||
|
const Value& GetValue(void) const
|
||||||
|
{
|
||||||
|
return m_Value;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue