Skip to content

Commit 6f4274d

Browse files
author
Daniel Kroening
committed
deprecates exprt::move_to_operands(...)
Since sharing has been introduced there is no measureable performance benefit when using move_to_operands compared to copying: for(int i=0; i<2000000; i++) { irep_idt id; symbol_exprt s(id, bool_typet()); exprt something; something.move_to_operands(s); //something.copy_to_operands(s); } with move_to_operands: 0.59s with copy_to_operands: 0.55s This does not appear to require a recent compiler. Thus, there is no reason to believe that moving ireps would be any faster than copying. Moving has the additional disadvantage that there is a side-effect on the object that is moved. A scenario in which moving offers a benefit is the idiom in which 1) an irep x is copied, 2) the copy is then subsequently modified, 3) x is then destroyed. The proposal is to do step 1) via an rvalue reference and std::move() instead.
1 parent 356ab40 commit 6f4274d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/util/expr.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,13 @@ class exprt:public irept
105105
void reserve_operands(operandst::size_type n)
106106
{ operands().reserve(n) ; }
107107

108+
DEPRECATED("use copy_to_operands(expr) instead")
108109
void move_to_operands(exprt &expr);
110+
111+
DEPRECATED("use copy_to_operands(e1, e2) instead")
109112
void move_to_operands(exprt &e1, exprt &e2);
113+
114+
DEPRECATED("use copy_to_operands(e1, e2, e3) instead")
110115
void move_to_operands(exprt &e1, exprt &e2, exprt &e3);
111116

112117
/// Copy the given argument to the end of `exprt`'s operands.

0 commit comments

Comments
 (0)