Skip to content

Commit

Permalink
Move getConflictingAltSubsets calculation, reduce its usage
Browse files Browse the repository at this point in the history
This patch moves the calculation of conflicting als subsets in
ParserATNSimulator::execATNWithFullContext() to the point where it
is actually needed.
In our benchmark, this saves about 10% of calls to
getConflictingAltSubsets().

Signed-off-by: Andreas Buhr <[email protected]>
  • Loading branch information
andreasbuhr committed Apr 11, 2024
1 parent 380ce4b commit 5e3dbe6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,13 @@ size_t ParserATNSimulator::execATNWithFullContext(dfa::DFA &dfa, dfa::DFAState *
delete previous;
previous = nullptr;

std::vector<BitSet> altSubSets = PredictionModeClass::getConflictingAltSubsets(reach.get());
reach->uniqueAlt = getUniqueAlt(reach.get());
// unique prediction?
if (reach->uniqueAlt != ATN::INVALID_ALT_NUMBER) {
predictedAlt = reach->uniqueAlt;
break;
}
std::vector<BitSet> altSubSets = PredictionModeClass::getConflictingAltSubsets(reach.get());
if (_mode != PredictionMode::LL_EXACT_AMBIG_DETECTION) {
predictedAlt = PredictionModeClass::resolvesToJustOneViableAlt(altSubSets);
if (predictedAlt != ATN::INVALID_ALT_NUMBER) {
Expand Down

0 comments on commit 5e3dbe6

Please sign in to comment.