@@ -677,16 +677,16 @@ static Constraint *determineBestChoicesInContext(
677
677
getLogger () << " )\n " ;
678
678
}
679
679
680
+ if (bestOverallScore == 0 )
681
+ return nullptr ;
682
+
680
683
for (auto &entry : disjunctionScores) {
681
684
TinyPtrVector<Constraint *> favoredChoices;
682
685
for (auto *choice : favoredChoicesPerDisjunction[entry.first ])
683
686
favoredChoices.push_back (choice);
684
687
favorings[entry.first ] = std::make_pair (entry.second , favoredChoices);
685
688
}
686
689
687
- if (bestOverallScore == 0 )
688
- return nullptr ;
689
-
690
690
Constraint *bestDisjunction = nullptr ;
691
691
for (auto *disjunction : disjunctions) {
692
692
if (disjunctionScores[disjunction] != bestOverallScore)
@@ -788,8 +788,13 @@ ConstraintSystem::selectDisjunction() {
788
788
auto &[firstScore, firstFavoredChoices] = favorings[first];
789
789
auto &[secondScore, secondFavoredChoices] = favorings[second];
790
790
791
- if (firstScore > secondScore)
792
- return true ;
791
+ // Rank based on scores only if both disjunctions are supported.
792
+ if (isSupportedDisjunction (first) && isSupportedDisjunction (second)) {
793
+ // If both disjunctions have the same score they should be ranked
794
+ // based on number of favored/active choices.
795
+ if (firstScore != secondScore)
796
+ return firstScore > secondScore;
797
+ }
793
798
794
799
unsigned numFirstFavored = firstFavoredChoices.size ();
795
800
unsigned numSecondFavored = secondFavoredChoices.size ();
0 commit comments