From d072c6bc22da96d056fd02f36708ef60e9ad048b Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 10 Nov 2022 12:49:11 +0100 Subject: [PATCH] IndexerExpression#GetReference(): ref, not copy, index if it's a literal string --- lib/config/expression.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/config/expression.cpp b/lib/config/expression.cpp index 65e0a3e97..43d164faf 100644 --- a/lib/config/expression.cpp +++ b/lib/config/expression.cpp @@ -792,8 +792,14 @@ bool IndexerExpression::GetReference(ScriptFrame& frame, bool init_dict, Value * *parent = operand1.GetValue(); } - ExpressionResult operand2 = m_Operand2->Evaluate(frame); - index->Set(operand2.GetValue()); + auto lit (dynamic_cast(m_Operand2.get())); + + if (lit && lit->GetValue().IsString()) { + index->Set(&lit->GetValue().Get()); + } else { + ExpressionResult operand2 = m_Operand2->Evaluate(frame); + index->Set(operand2.GetValue()); + } if (dhint) { if (psdhint)