Skip to content

Commit f765390

Browse files
committed
[ConstraintSystem] Convert Fixes to a set vector to avoid duplicates
1 parent d74e8c9 commit f765390

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,7 @@ class ConstraintSystem {
23772377
ConstraintRestrictions;
23782378

23792379
/// The set of fixes applied to make the solution work.
2380-
llvm::SmallVector<ConstraintFix *, 4> Fixes;
2380+
llvm::SmallSetVector<ConstraintFix *, 4> Fixes;
23812381

23822382
/// The set of remembered disjunction choices used to reach
23832383
/// the current constraint system.
@@ -3420,7 +3420,7 @@ class ConstraintSystem {
34203420
return !solverState || solverState->recordFixes;
34213421
}
34223422

3423-
ArrayRef<ConstraintFix *> getFixes() const { return Fixes; }
3423+
ArrayRef<ConstraintFix *> getFixes() const { return Fixes.getArrayRef(); }
34243424

34253425
bool shouldSuppressDiagnostics() const {
34263426
return Options.contains(ConstraintSystemFlags::SuppressDiagnostics);

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11516,7 +11516,7 @@ bool ConstraintSystem::recordFix(ConstraintFix *fix, unsigned impact) {
1151611516
return true;
1151711517

1151811518
if (isAugmentingFix(fix)) {
11519-
Fixes.push_back(fix);
11519+
Fixes.insert(fix);
1152011520
return false;
1152111521
}
1152211522

@@ -11541,7 +11541,7 @@ bool ConstraintSystem::recordFix(ConstraintFix *fix, unsigned impact) {
1154111541
}
1154211542

1154311543
if (!found)
11544-
Fixes.push_back(fix);
11544+
Fixes.insert(fix);
1154511545

1154611546
return false;
1154711547
}

lib/Sema/CSSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ void ConstraintSystem::applySolution(const Solution &solution) {
309309
}
310310

311311
// Register any fixes produced along this path.
312-
Fixes.append(solution.Fixes.begin(), solution.Fixes.end());
312+
Fixes.insert(solution.Fixes.begin(), solution.Fixes.end());
313313
}
314314

315315
/// Restore the type variable bindings to what they were before

0 commit comments

Comments
 (0)