@@ -710,8 +710,7 @@ static Type getUnlabeledType(Type type, ASTContext &ctx) {
710
710
711
711
SolutionCompareResult ConstraintSystem::compareSolutions (
712
712
ConstraintSystem &cs, ArrayRef<Solution> solutions,
713
- const SolutionDiff &diff, unsigned idx1, unsigned idx2,
714
- llvm::DenseMap<Expr *, std::pair<unsigned , Expr *>> &weights) {
713
+ const SolutionDiff &diff, unsigned idx1, unsigned idx2) {
715
714
if (cs.getASTContext ().LangOpts .DebugConstraintSolver ) {
716
715
auto &log = cs.getASTContext ().TypeCheckerDebug ->getStream ();
717
716
log.indent (cs.solverState ->depth * 2 )
@@ -743,9 +742,9 @@ SolutionCompareResult ConstraintSystem::compareSolutions(
743
742
744
743
auto getWeight = [&](ConstraintLocator *locator) -> unsigned {
745
744
if (auto *anchor = locator->getAnchor ()) {
746
- auto weight = weights. find (anchor);
747
- if (weight != weights. end () )
748
- return weight-> getSecond (). first + 1 ;
745
+ auto weight = cs. getExprDepth (anchor);
746
+ if (weight)
747
+ return * weight + 1 ;
749
748
}
750
749
751
750
return 1 ;
@@ -1197,7 +1196,7 @@ ConstraintSystem::findBestSolution(SmallVectorImpl<Solution> &viable,
1197
1196
SmallVector<bool , 16 > losers (viable.size (), false );
1198
1197
unsigned bestIdx = 0 ;
1199
1198
for (unsigned i = 1 , n = viable.size (); i != n; ++i) {
1200
- switch (compareSolutions (*this , viable, diff, i, bestIdx, ExprWeights )) {
1199
+ switch (compareSolutions (*this , viable, diff, i, bestIdx)) {
1201
1200
case SolutionCompareResult::Identical:
1202
1201
// FIXME: Might want to warn about this in debug builds, so we can
1203
1202
// find a way to eliminate the redundancy in the search space.
@@ -1221,7 +1220,7 @@ ConstraintSystem::findBestSolution(SmallVectorImpl<Solution> &viable,
1221
1220
if (i == bestIdx)
1222
1221
continue ;
1223
1222
1224
- switch (compareSolutions (*this , viable, diff, bestIdx, i, ExprWeights )) {
1223
+ switch (compareSolutions (*this , viable, diff, bestIdx, i)) {
1225
1224
case SolutionCompareResult::Identical:
1226
1225
// FIXME: Might want to warn about this in debug builds, so we can
1227
1226
// find a way to eliminate the redundancy in the search space.
@@ -1273,7 +1272,7 @@ ConstraintSystem::findBestSolution(SmallVectorImpl<Solution> &viable,
1273
1272
if (losers[j])
1274
1273
continue ;
1275
1274
1276
- switch (compareSolutions (*this , viable, diff, i, j, ExprWeights )) {
1275
+ switch (compareSolutions (*this , viable, diff, i, j)) {
1277
1276
case SolutionCompareResult::Identical:
1278
1277
// FIXME: Dub one of these the loser arbitrarily?
1279
1278
break ;
0 commit comments