Skip to content

Commit cc2aa2b

Browse files
committed
IndexerExpression#GetReference(): ref, not copy, index if it's a literal string
1 parent fd26c6e commit cc2aa2b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/config/expression.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,8 +800,14 @@ bool IndexerExpression::GetReference(ScriptFrame& frame, bool init_dict, Value *
800800
*parent = operand1.GetValue();
801801
}
802802

803-
ExpressionResult operand2 = m_Operand2->Evaluate(frame);
804-
index->Set(operand2.GetValue());
803+
auto lit (dynamic_cast<LiteralExpression*>(m_Operand2.get()));
804+
805+
if (lit && lit->GetValue().IsString()) {
806+
index->Set(&lit->GetValue().Get<String>());
807+
} else {
808+
ExpressionResult operand2 = m_Operand2->Evaluate(frame);
809+
index->Set(operand2.GetValue());
810+
}
805811

806812
if (dhint) {
807813
if (psdhint)

0 commit comments

Comments
 (0)