From 5e3dbe6f912c62aecb1a07d1f7fa0531dc2b63b4 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Wed, 10 Apr 2024 18:02:17 +0200 Subject: [PATCH] Move getConflictingAltSubsets calculation, reduce its usage 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 --- runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp b/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp index 3a1537587c..1c031984d4 100755 --- a/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +++ b/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp @@ -388,13 +388,13 @@ size_t ParserATNSimulator::execATNWithFullContext(dfa::DFA &dfa, dfa::DFAState * delete previous; previous = nullptr; - std::vector 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 altSubSets = PredictionModeClass::getConflictingAltSubsets(reach.get()); if (_mode != PredictionMode::LL_EXACT_AMBIG_DETECTION) { predictedAlt = PredictionModeClass::resolvesToJustOneViableAlt(altSubSets); if (predictedAlt != ATN::INVALID_ALT_NUMBER) {