From 18ba6ebbd73fbcc00dc68e22878f97d7f647236c Mon Sep 17 00:00:00 2001 From: Phil Turnbull Date: Fri, 9 Jun 2017 16:13:17 -0400 Subject: [PATCH] Move state_id check into each_referenced_state --- src/compiler/build_tables/build_parse_table.cc | 3 +-- src/compiler/parse_table.cc | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/build_tables/build_parse_table.cc b/src/compiler/build_tables/build_parse_table.cc index d1d90455..50c84af7 100644 --- a/src/compiler/build_tables/build_parse_table.cc +++ b/src/compiler/build_tables/build_parse_table.cc @@ -394,8 +394,7 @@ class ParseTableBuilder { } else { ParseState &state = *iter; state.each_referenced_state([&new_state_ids](ParseStateId *state_index) { - if (*state_index != (ParseStateId)(-1)) - *state_index = new_state_ids[*state_index]; + *state_index = new_state_ids[*state_index]; }); ++iter; } diff --git a/src/compiler/parse_table.cc b/src/compiler/parse_table.cc index cf91154f..5b422d43 100644 --- a/src/compiler/parse_table.cc +++ b/src/compiler/parse_table.cc @@ -154,7 +154,8 @@ void ParseState::each_referenced_state(function fn) { if (action.type == ParseActionTypeShift || action.type == ParseActionTypeRecover) fn(&action.state_index); for (auto &entry : nonterminal_entries) - fn(&entry.second); + if (entry.second != (ParseStateId)(-1)) + fn(&entry.second); } bool ParseState::operator==(const ParseState &other) const {