@@ -1646,8 +1646,9 @@ PotentialBindings::inferFromRelational(ConstraintSystem &CS,
1646
1646
findInferableTypeVars (second, typeVars);
1647
1647
1648
1648
if (typeVars.erase (TypeVar)) {
1649
- for (auto *typeVar : typeVars)
1650
- AdjacentVars.insert ({typeVar, constraint});
1649
+ for (auto *typeVar : typeVars) {
1650
+ AdjacentVars.emplace_back (typeVar, constraint);
1651
+ }
1651
1652
}
1652
1653
1653
1654
// Infer a binding from `inout $T <convertible to> Unsafe*Pointer<...>?`.
@@ -1772,7 +1773,7 @@ PotentialBindings::inferFromRelational(ConstraintSystem &CS,
1772
1773
// Add all type variables encountered in the type except
1773
1774
// to the current type variable.
1774
1775
if (var != TypeVar) {
1775
- AdjacentVars.insert ({ var, constraint} );
1776
+ AdjacentVars.emplace_back ( var, constraint);
1776
1777
continue ;
1777
1778
}
1778
1779
@@ -1833,26 +1834,26 @@ PotentialBindings::inferFromRelational(ConstraintSystem &CS,
1833
1834
case ConstraintKind::ArgumentConversion:
1834
1835
case ConstraintKind::OperatorArgumentConversion: {
1835
1836
if (kind == AllowedBindingKind::Subtypes) {
1836
- SubtypeOf.insert ({ bindingTypeVar, constraint} );
1837
+ SubtypeOf.emplace_back ( bindingTypeVar, constraint);
1837
1838
} else {
1838
1839
assert (kind == AllowedBindingKind::Supertypes);
1839
- SupertypeOf.insert ({ bindingTypeVar, constraint} );
1840
+ SupertypeOf.emplace_back ( bindingTypeVar, constraint);
1840
1841
}
1841
1842
1842
- AdjacentVars.insert ({ bindingTypeVar, constraint} );
1843
+ AdjacentVars.emplace_back ( bindingTypeVar, constraint);
1843
1844
break ;
1844
1845
}
1845
1846
1846
1847
case ConstraintKind::Bind:
1847
1848
case ConstraintKind::BindParam:
1848
1849
case ConstraintKind::Equal: {
1849
- EquivalentTo.insert ({ bindingTypeVar, constraint} );
1850
- AdjacentVars.insert ({ bindingTypeVar, constraint} );
1850
+ EquivalentTo.emplace_back ( bindingTypeVar, constraint);
1851
+ AdjacentVars.emplace_back ( bindingTypeVar, constraint);
1851
1852
break ;
1852
1853
}
1853
1854
1854
1855
case ConstraintKind::UnresolvedMemberChainBase: {
1855
- EquivalentTo.insert ({ bindingTypeVar, constraint} );
1856
+ EquivalentTo.emplace_back ( bindingTypeVar, constraint);
1856
1857
1857
1858
// Don't record adjacency between base and result types,
1858
1859
// this is just an auxiliary constraint to enforce ordering.
@@ -1864,8 +1865,9 @@ PotentialBindings::inferFromRelational(ConstraintSystem &CS,
1864
1865
// an un-inferred optional is adjacent to a type
1865
1866
// variable that presents such optional (`bindingTypeVar`
1866
1867
// in this case).
1867
- if (kind == AllowedBindingKind::Supertypes)
1868
- AdjacentVars.insert ({bindingTypeVar, constraint});
1868
+ if (kind == AllowedBindingKind::Supertypes) {
1869
+ AdjacentVars.emplace_back (bindingTypeVar, constraint);
1870
+ }
1869
1871
break ;
1870
1872
}
1871
1873
@@ -2088,33 +2090,34 @@ void PotentialBindings::retract(ConstraintSystem &CS,
2088
2090
}),
2089
2091
Bindings.end ());
2090
2092
2091
- {
2092
- llvm::SmallPtrSet<TypeVariableType *, 2 > unviable;
2093
- for (const auto &adjacent : AdjacentVars) {
2094
- if (adjacent.second == constraint)
2095
- unviable.insert (adjacent.first );
2096
- }
2097
-
2098
- for (auto *adjacentVar : unviable)
2099
- AdjacentVars.erase (std::make_pair (adjacentVar, constraint));
2100
- }
2101
-
2102
- auto isMatchingConstraint = [&constraint](Constraint *existing) {
2103
- return existing == constraint;
2104
- };
2105
-
2106
- DelayedBy.erase (llvm::remove_if (DelayedBy, isMatchingConstraint),
2107
- DelayedBy.end ());
2093
+ DelayedBy.erase (
2094
+ llvm::remove_if (DelayedBy,
2095
+ [&constraint](Constraint *existing) {
2096
+ return existing == constraint;
2097
+ }),
2098
+ DelayedBy.end ());
2108
2099
2109
2100
auto hasMatchingSource =
2110
2101
[&constraint](
2111
2102
const std::pair<TypeVariableType *, Constraint *> &adjacency) {
2112
2103
return adjacency.second == constraint;
2113
2104
};
2114
2105
2115
- SubtypeOf.remove_if (hasMatchingSource);
2116
- SupertypeOf.remove_if (hasMatchingSource);
2117
- EquivalentTo.remove_if (hasMatchingSource);
2106
+ AdjacentVars.erase (
2107
+ llvm::remove_if (AdjacentVars, hasMatchingSource),
2108
+ AdjacentVars.end ());
2109
+
2110
+ SubtypeOf.erase (
2111
+ llvm::remove_if (SubtypeOf, hasMatchingSource),
2112
+ SubtypeOf.end ());
2113
+
2114
+ SupertypeOf.erase (
2115
+ llvm::remove_if (SupertypeOf, hasMatchingSource),
2116
+ SupertypeOf.end ());
2117
+
2118
+ EquivalentTo.erase (
2119
+ llvm::remove_if (EquivalentTo, hasMatchingSource),
2120
+ EquivalentTo.end ());
2118
2121
}
2119
2122
2120
2123
void PotentialBindings::reset () {
0 commit comments