Skip to content

Commit eabd67c

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 0ea7f13 commit eabd67c

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
@@ -101,9 +101,7 @@ guard_exprt &operator-=(guard_exprt &g1, const guard_exprt &g2)
101101
return g1;
102102
}
103103

104-
sort_and_join(g1.expr);
105104
exprt g2_sorted = g2.as_expr();
106-
sort_and_join(g2_sorted);
107105

108106
exprt::operandst &op1 = g1.expr.operands();
109107
const exprt::operandst &op2 = g2_sorted.operands();
@@ -112,10 +110,10 @@ guard_exprt &operator-=(guard_exprt &g1, const guard_exprt &g2)
112110
for(exprt::operandst::const_iterator it2 = op2.begin(); it2 != op2.end();
113111
++it2)
114112
{
115-
while(it1 != op1.end() && *it1 < *it2)
116-
++it1;
117113
if(it1 != op1.end() && *it1 == *it2)
118114
it1 = op1.erase(it1);
115+
else
116+
break;
119117
}
120118

121119
g1.expr = conjunction(op1);
@@ -159,9 +157,7 @@ guard_exprt &operator|=(guard_exprt &g1, const guard_exprt &g2)
159157
}
160158

161159
// find common prefix
162-
sort_and_join(g1.expr);
163160
exprt g2_sorted = g2.as_expr();
164-
sort_and_join(g2_sorted);
165161

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

0 commit comments

Comments
 (0)