Skip to content

Commit 4108352

Browse files
committed
[CS] Remove ConstraintGraph::removeEdge
The only caller was `contractEdges`, which would only call it with constraints from either the active or inactive list. The implementation can therefore be replaced by `ConstraintSystem::retireConstraint`, and `removeGeneratedConstraint` can also be removed.
1 parent 82cdf91 commit 4108352

File tree

3 files changed

+2
-53
lines changed

3 files changed

+2
-53
lines changed

lib/Sema/ConstraintGraph.cpp

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,8 +1165,8 @@ bool ConstraintGraph::contractEdges() {
11651165
log << "\n";
11661166
}
11671167

1168-
// Merge the edges and remove the constraint.
1169-
removeEdge(constraint);
1168+
// Merge the edges and retire the constraint.
1169+
CS.retireConstraint(constraint);
11701170
if (rep1 != rep2)
11711171
CS.mergeEquivalenceClasses(rep1, rep2, /*updateWorkList*/ false);
11721172
didContractEdges = true;
@@ -1175,35 +1175,6 @@ bool ConstraintGraph::contractEdges() {
11751175
return didContractEdges;
11761176
}
11771177

1178-
void ConstraintGraph::removeEdge(Constraint *constraint) {
1179-
bool isExistingConstraint = false;
1180-
1181-
for (auto &active : CS.ActiveConstraints) {
1182-
if (&active == constraint) {
1183-
CS.ActiveConstraints.erase(constraint);
1184-
isExistingConstraint = true;
1185-
break;
1186-
}
1187-
}
1188-
1189-
for (auto &inactive : CS.InactiveConstraints) {
1190-
if (&inactive == constraint) {
1191-
CS.InactiveConstraints.erase(constraint);
1192-
isExistingConstraint = true;
1193-
break;
1194-
}
1195-
}
1196-
1197-
if (CS.solverState) {
1198-
if (isExistingConstraint)
1199-
CS.solverState->retireConstraint(constraint);
1200-
else
1201-
CS.solverState->removeGeneratedConstraint(constraint);
1202-
}
1203-
1204-
removeConstraint(constraint);
1205-
}
1206-
12071178
void ConstraintGraph::optimize() {
12081179
// Merge equivalence classes until a fixed point is reached.
12091180
while (contractEdges()) {}

lib/Sema/ConstraintGraph.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,6 @@ class ConstraintGraph {
333333
/// classes until a fixed point is reached.
334334
bool contractEdges();
335335

336-
/// To support edge contraction, remove a constraint from both the constraint
337-
/// graph and its enclosing constraint system.
338-
void removeEdge(Constraint *constraint);
339-
340336
/// The constraint system.
341337
ConstraintSystem &CS;
342338

lib/Sema/ConstraintSystem.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,24 +1928,6 @@ class ConstraintSystem {
19281928
generatedConstraints.push_back(constraint);
19291929
}
19301930

1931-
/// Erase given constraint from the list of generated constraints
1932-
/// along the current solver path. Note that this operation doesn't
1933-
/// guarantee any ordering of the after it's application.
1934-
///
1935-
/// \param constraint The constraint to erase.
1936-
void removeGeneratedConstraint(Constraint *constraint) {
1937-
for (auto *&generated : generatedConstraints) {
1938-
// When we find the constraint we're erasing, overwrite its
1939-
// value with the last element in the generated constraints
1940-
// vector and then pop that element from the vector.
1941-
if (generated == constraint) {
1942-
generated = generatedConstraints.back();
1943-
generatedConstraints.pop_back();
1944-
return;
1945-
}
1946-
}
1947-
}
1948-
19491931
/// Register given scope to be tracked by the current solver state,
19501932
/// this helps to make sure that all of the retired/generated constraints
19511933
/// are dealt with correctly when the life time of the scope ends.

0 commit comments

Comments
 (0)