Skip to content

Commit d5172fa

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

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
@@ -791,8 +791,14 @@ bool IndexerExpression::GetReference(ScriptFrame& frame, bool init_dict, Value *
791791
*parent = operand1.GetValue();
792792
}
793793

794-
ExpressionResult operand2 = m_Operand2->Evaluate(frame);
795-
index->Set(operand2.GetValue());
794+
auto lit (dynamic_cast<LiteralExpression*>(m_Operand2.get()));
795+
796+
if (lit && lit->GetValue().IsString()) {
797+
index->Set(&lit->GetValue().Get<String>());
798+
} else {
799+
ExpressionResult operand2 = m_Operand2->Evaluate(frame);
800+
index->Set(operand2.GetValue());
801+
}
796802

797803
if (dhint) {
798804
if (psdhint)

0 commit comments

Comments
 (0)