Switch Clause to Ptr (#800)

This is consistent with other lists, doesn't seem to benefit from being a Ptr.
This commit is contained in:
Jon Meow
2021-09-01 15:19:58 -07:00
committed by GitHub
parent 9f67c4b9a8
commit 5f8b231322
5 changed files with 24 additions and 33 deletions
@@ -765,12 +765,12 @@ auto Interpreter::StepStmt() -> Transition {
// * 2: the pattern for clause 1
// * ...
auto clause_num = (act->Pos() - 1) / 2;
if (clause_num >= static_cast<int>(match_stmt.Clauses()->size())) {
if (clause_num >= static_cast<int>(match_stmt.Clauses().size())) {
DeallocateScope(frame->scopes.Top());
frame->scopes.Pop();
return Done{};
}
auto c = match_stmt.Clauses()->begin();
auto c = match_stmt.Clauses().begin();
std::advance(c, clause_num);
if (act->Pos() % 2 == 1) {
@@ -784,7 +784,7 @@ auto Interpreter::StepStmt() -> Transition {
std::optional<Env> matches = PatternMatch(pat, v, stmt->SourceLoc());
if (matches) { // we have a match, start the body
// Ensure we don't process any more clauses.
act->SetPos(2 * match_stmt.Clauses()->size() + 1);
act->SetPos(2 * match_stmt.Clauses().size() + 1);
for (const auto& [name, value] : *matches) {
frame->scopes.Top()->values.Set(name, value);