Skip to content

Commit f4a99f0

Browse files
committed
Do not unnecessarily sort guard conjuncts
Guards are (no longer) generic conjunctions. They are constructed in a consistent order. If a more generic set-up is required, use BDD-backed guards.
1 parent 7bbef4a commit f4a99f0

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/analyses/guard_expr.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ guard_exprt &operator-=(guard_exprt &g1, const guard_exprt &g2)
6969
if(g1.expr.id() != ID_and || g2.expr.id() != ID_and)
7070
return g1;
7171

72-
sort_and_join(g1.expr);
7372
exprt g2_sorted = g2.as_expr();
74-
sort_and_join(g2_sorted);
7573

7674
exprt::operandst &op1 = g1.expr.operands();
7775
const exprt::operandst &op2 = g2_sorted.operands();
@@ -80,10 +78,10 @@ guard_exprt &operator-=(guard_exprt &g1, const guard_exprt &g2)
8078
for(exprt::operandst::const_iterator it2 = op2.begin(); it2 != op2.end();
8179
++it2)
8280
{
83-
while(it1 != op1.end() && *it1 < *it2)
84-
++it1;
8581
if(it1 != op1.end() && *it1 == *it2)
8682
it1 = op1.erase(it1);
83+
else
84+
break;
8785
}
8886

8987
g1.expr = conjunction(op1);
@@ -116,9 +114,7 @@ guard_exprt &operator|=(guard_exprt &g1, const guard_exprt &g2)
116114
}
117115

118116
// find common prefix
119-
sort_and_join(g1.expr);
120117
exprt g2_sorted = g2.as_expr();
121-
sort_and_join(g2_sorted);
122118

123119
exprt::operandst &op1 = g1.expr.operands();
124120
const exprt::operandst &op2 = g2_sorted.operands();

0 commit comments

Comments
 (0)