@@ -571,20 +571,17 @@ void ConstraintGraph::retractBindings(TypeVariableType *typeVar,
571
571
// /
572
572
// / \param cg The constraint graph.
573
573
// / \param typeVar The type variable we're searching from.
574
- // / \param preVisitNode Called before traversing a node. Must return \c
575
- // / false when the node has already been visited.
576
- // / \param visitConstraint Called before considering a constraint. If it
577
- // / returns \c false, that constraint will be skipped.
574
+ // / \param visitConstraint Called before considering a constraint.
578
575
// / \param visitedConstraints Set of already-visited constraints, used
579
576
// / internally to avoid duplicated work.
580
577
static void depthFirstSearch (
581
578
ConstraintGraph &cg,
582
579
TypeVariableType *typeVar,
583
- llvm::function_ref<bool (TypeVariableType *)> preVisitNode ,
584
- llvm::function_ref<bool(Constraint *)> visitConstraint ,
580
+ llvm::function_ref<void (Constraint *)> visitConstraint ,
581
+ llvm::SmallPtrSet<TypeVariableType *, 4> &typeVars ,
585
582
llvm::SmallPtrSet<Constraint *, 8> &visitedConstraints) {
586
583
// Visit this node. If we've already seen it, bail out.
587
- if (!preVisitNode (typeVar))
584
+ if (!typeVars. insert (typeVar). second )
588
585
return ;
589
586
590
587
// Local function to visit adjacent type variables.
@@ -594,21 +591,18 @@ static void depthFirstSearch(
594
591
continue ;
595
592
596
593
// Recurse into this node.
597
- depthFirstSearch (cg, adj, preVisitNode, visitConstraint,
598
- visitedConstraints);
594
+ depthFirstSearch (cg, adj, visitConstraint, typeVars, visitedConstraints);
599
595
}
600
596
};
601
597
602
- // Walk all of the constraints associated with this node to find related
603
- // nodes.
598
+ // Walk all of the constraints associated with this node.
604
599
auto &node = cg[typeVar];
605
600
for (auto constraint : node.getConstraints ()) {
606
601
// If we've already seen this constraint, skip it.
607
602
if (!visitedConstraints.insert (constraint).second )
608
603
continue ;
609
604
610
- if (visitConstraint (constraint))
611
- visitAdjacencies (constraint->getTypeVariables ());
605
+ visitConstraint (constraint);
612
606
}
613
607
614
608
// Visit all of the other nodes in the equivalence class.
@@ -639,17 +633,11 @@ llvm::TinyPtrVector<Constraint *> ConstraintGraph::gatherConstraints(
639
633
// constraints involving both it and its fixed bindings.
640
634
depthFirstSearch (
641
635
*this , typeVar,
642
- [&](TypeVariableType *typeVar) {
643
- return typeVars.insert (typeVar).second ;
644
- },
645
636
[&](Constraint *constraint) {
646
637
if (acceptConstraintFn (constraint))
647
638
constraints.push_back (constraint);
648
-
649
- // Don't recurse into the constraint's type variables.
650
- return false ;
651
639
},
652
- visitedConstraints);
640
+ typeVars, visitedConstraints);
653
641
return constraints;
654
642
}
655
643
0 commit comments