[Constraint graph] Move constraint uniquing into gatherConstraints().

Simplify the interface to gatherConstraints() by performing the
uniquing within the function itself and returning only the resulting
(uniqued) vector of constraints.
This commit is contained in:
Doug Gregor
2019-07-25 02:13:27 -04:00
parent dfdd352d3d
commit 8355f3d270
8 changed files with 65 additions and 67 deletions

View File

@@ -205,9 +205,8 @@ void ConstraintSystem::assignFixedType(TypeVariableType *typeVar, Type type,
void ConstraintSystem::addTypeVariableConstraintsToWorkList(
TypeVariableType *typeVar) {
// Gather the constraints affected by a change to this type variable.
llvm::SetVector<Constraint *> inactiveConstraints;
CG.gatherConstraints(
typeVar, inactiveConstraints, ConstraintGraph::GatheringKind::AllMentions,
auto inactiveConstraints = CG.gatherConstraints(
typeVar, ConstraintGraph::GatheringKind::AllMentions,
[](Constraint *constraint) { return !constraint->isActive(); });
// Add any constraints that aren't already active to the worklist.
@@ -1985,13 +1984,13 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
increaseScore(SK_KeyPathSubscript);
auto dynamicResultTy = boundType->castTo<TypeVariableType>();
llvm::SetVector<Constraint *> constraints;
CG.gatherConstraints(dynamicResultTy, constraints,
ConstraintGraph::GatheringKind::EquivalenceClass,
[](Constraint *constraint) {
return constraint->getKind() ==
ConstraintKind::ApplicableFunction;
});
auto constraints = CG.gatherConstraints(
dynamicResultTy,
ConstraintGraph::GatheringKind::EquivalenceClass,
[](Constraint *constraint) {
return constraint->getKind() ==
ConstraintKind::ApplicableFunction;
});
assert(constraints.size() == 1);
auto *applicableFn = constraints.front();