mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ConstraintGraph] Use set to gather constraints for type variables
Since it's possible to find the same constraint through two different but equivalent type variables, let's use a set to store constraints instead of a vector to avoid processing the same constraint multiple times.
This commit is contained in:
@@ -467,9 +467,8 @@ void ConstraintGraph::unbindTypeVariable(TypeVariableType *typeVar, Type fixed){
|
||||
}
|
||||
|
||||
void ConstraintGraph::gatherConstraints(
|
||||
TypeVariableType *typeVar,
|
||||
SmallVectorImpl<Constraint *> &constraints,
|
||||
GatheringKind kind) {
|
||||
TypeVariableType *typeVar, SmallPtrSetImpl<Constraint *> &constraints,
|
||||
GatheringKind kind) {
|
||||
auto &reprNode = (*this)[CS.getRepresentative(typeVar)];
|
||||
auto equivClass = reprNode.getEquivalenceClass();
|
||||
llvm::SmallPtrSet<TypeVariableType *, 4> typeVars;
|
||||
@@ -478,7 +477,7 @@ void ConstraintGraph::gatherConstraints(
|
||||
continue;
|
||||
|
||||
for (auto constraint : (*this)[typeVar].getConstraints())
|
||||
constraints.push_back(constraint);
|
||||
constraints.insert(constraint);
|
||||
|
||||
auto &node = (*this)[typeVar];
|
||||
|
||||
@@ -511,7 +510,7 @@ void ConstraintGraph::gatherConstraints(
|
||||
continue;
|
||||
|
||||
for (auto constraint : (*this)[adjTypeVarEquiv].getConstraints())
|
||||
constraints.push_back(constraint);
|
||||
constraints.insert(constraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user