diff --git a/binder/scope.cpp b/binder/scope.cpp index 973869c45cdc75588dd58bf088a8b21da365b7a1..5e2fe718dd6755b01563e0104c14010f7a530ae9 100644 --- a/binder/scope.cpp +++ b/binder/scope.cpp @@ -256,7 +256,8 @@ void VariableScope::CheckDirectEval(compiler::CompilerContext *compilerCtx) } } - std::vector literals(LexicalSlots() + constBindings); + std::vector literals; + literals.reserve(LexicalSlots() + constBindings); if (constBindings == 0U) { for (const auto &[name, variable] : bindings_) { @@ -264,26 +265,18 @@ void VariableScope::CheckDirectEval(compiler::CompilerContext *compilerCtx) continue; } - literals[variable->AsLocalVariable()->LexIdx()] = compiler::Literal(name); + literals.emplace_back(compiler::Literal(name)); } } else { - std::vector bindings(LexicalSlots()); - for (const auto &[name, variable] : bindings_) { (void)name; if (!variable->LexicalBound()) { continue; } - - bindings[variable->AsLocalVariable()->LexIdx()] = variable; - } - - uint32_t buffIndex = 0; - for (const auto *variable : bindings) { if (variable->Declaration()->IsConstDecl()) { - literals[buffIndex++] = compiler::Literal(true); + literals.emplace_back(compiler::Literal(true)); } - literals[buffIndex++] = compiler::Literal(variable->Name()); + literals.emplace_back(compiler::Literal(variable->Name())); } } diff --git a/compiler/core/emitter.cpp b/compiler/core/emitter.cpp index d854586e297d8e57593853f89ed0292b1d04df32..605c0579dfacefe4f15b1c6e282324ebb5db6c39 100644 --- a/compiler/core/emitter.cpp +++ b/compiler/core/emitter.cpp @@ -98,6 +98,7 @@ static LiteralPair TransformLiteral(const compiler::Literal *literal) break; } default: + UNREACHABLE(); break; }