Skip to content

Commit 90ca430

Browse files
authored
Merge pull request #18240 from rudkx/tweak-short-circuit
[ConstraintSystem] Minor tweak to short-circuiting logic in solver.
2 parents 665bcb9 + 11b1910 commit 90ca430

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,13 +2032,14 @@ bool ConstraintSystem::solveForDisjunctionChoices(
20322032
// short-circuit the disjunction.
20332033
if (lastSolvedChoice) {
20342034
Constraint *lastChoice = lastSolvedChoice->first;
2035-
auto &score = lastSolvedChoice->second;
2036-
bool hasUnavailableOverloads = score.Data[SK_Unavailable] > 0;
2037-
bool hasFixes = score.Data[SK_Fix] > 0;
2038-
2039-
// Attempt to short-circuit disjunction only if score indicates
2040-
// that there are no unavailable overload choices present in the
2041-
// solution, and the solution does not involve fixes.
2035+
auto delta = lastSolvedChoice->second - CurrentScore;
2036+
bool hasUnavailableOverloads = delta.Data[SK_Unavailable] > 0;
2037+
bool hasFixes = delta.Data[SK_Fix] > 0;
2038+
2039+
// Attempt to short-circuit evaluation of this disjunction only
2040+
// if the disjunction choice we are comparing to did not involve
2041+
// selecting unavailable overloads or result in fixes being
2042+
// applied to reach a solution.
20422043
if (!hasUnavailableOverloads && !hasFixes &&
20432044
shortCircuitDisjunctionAt(currentChoice, lastChoice, getASTContext()))
20442045
break;

0 commit comments

Comments
 (0)