mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CSOptimizer] Rank disjunctions based on score only if both sides are supported
This commit is contained in:
@@ -677,6 +677,9 @@ static Constraint *determineBestChoicesInContext(
|
||||
getLogger() << ")\n";
|
||||
}
|
||||
|
||||
if (bestOverallScore == 0)
|
||||
return nullptr;
|
||||
|
||||
for (auto &entry : disjunctionScores) {
|
||||
TinyPtrVector<Constraint *> favoredChoices;
|
||||
for (auto *choice : favoredChoicesPerDisjunction[entry.first])
|
||||
@@ -684,9 +687,6 @@ static Constraint *determineBestChoicesInContext(
|
||||
favorings[entry.first] = std::make_pair(entry.second, favoredChoices);
|
||||
}
|
||||
|
||||
if (bestOverallScore == 0)
|
||||
return nullptr;
|
||||
|
||||
Constraint *bestDisjunction = nullptr;
|
||||
for (auto *disjunction : disjunctions) {
|
||||
if (disjunctionScores[disjunction] != bestOverallScore)
|
||||
@@ -788,8 +788,13 @@ ConstraintSystem::selectDisjunction() {
|
||||
auto &[firstScore, firstFavoredChoices] = favorings[first];
|
||||
auto &[secondScore, secondFavoredChoices] = favorings[second];
|
||||
|
||||
if (firstScore > secondScore)
|
||||
return true;
|
||||
// Rank based on scores only if both disjunctions are supported.
|
||||
if (isSupportedDisjunction(first) && isSupportedDisjunction(second)) {
|
||||
// If both disjunctions have the same score they should be ranked
|
||||
// based on number of favored/active choices.
|
||||
if (firstScore != secondScore)
|
||||
return firstScore > secondScore;
|
||||
}
|
||||
|
||||
unsigned numFirstFavored = firstFavoredChoices.size();
|
||||
unsigned numSecondFavored = secondFavoredChoices.size();
|
||||
|
||||
Reference in New Issue
Block a user