Skip to content

Commit a5bb7a3

Browse files
authored
Merge pull request swiftlang#19924 from xedin/use-splice-to-move-to-active
[CSSolver] NFC: Replace `erase` with `splice` while returning constra…
2 parents 839e68f + 3e68e96 commit a5bb7a3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,17 +443,21 @@ ConstraintSystem::SolverState::~SolverState() {
443443
if (constraint->isActive())
444444
continue;
445445

446+
#ifndef NDEBUG
446447
// Make sure that constraint is present in the "inactive" set
447448
// before transferring it to "active".
448449
auto existing = llvm::find_if(CS.InactiveConstraints,
449450
[&constraint](const Constraint &inactive) {
450451
return &inactive == constraint;
451452
});
452-
assert(existing != CS.InactiveConstraints.end());
453+
assert(existing != CS.InactiveConstraints.end() &&
454+
"All constraints should be present in 'inactive' list");
455+
#endif
453456

454457
// Transfer the constraint to "active" set.
455-
CS.InactiveConstraints.erase(existing);
456-
CS.ActiveConstraints.push_back(constraint);
458+
CS.ActiveConstraints.splice(CS.ActiveConstraints.end(),
459+
CS.InactiveConstraints, constraint);
460+
457461
constraint->setActive(true);
458462
}
459463

0 commit comments

Comments
 (0)