Skip to content

Commit afef09f

Browse files
author
Joel Allred
committed
binary relation args as copy
This prevents a copy if the caller moves the arguments.
1 parent fbd21bb commit afef09f

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/util/string_expr.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,27 @@ Author: Romain Brenguier, [email protected]
1616
#include "refined_string_type.h"
1717
#include "std_expr.h"
1818

19-
inline binary_relation_exprt
20-
greater_or_equal_to(const exprt &lhs, const exprt &rhs)
19+
inline binary_relation_exprt greater_or_equal_to(exprt lhs, exprt rhs)
2120
{
2221
PRECONDITION(rhs.type() == lhs.type());
23-
return binary_relation_exprt(lhs, ID_ge, rhs);
22+
return binary_relation_exprt(std::move(lhs), ID_ge, std::move(rhs));
2423
}
2524

26-
inline binary_relation_exprt greater_than(const exprt &lhs, const exprt &rhs)
25+
inline binary_relation_exprt greater_than(exprt lhs, exprt rhs)
2726
{
2827
PRECONDITION(rhs.type() == lhs.type());
29-
return binary_relation_exprt(rhs, ID_lt, lhs);
28+
return binary_relation_exprt(std::move(rhs), ID_lt, std::move(lhs));
3029
}
3130

3231
inline binary_relation_exprt greater_than(const exprt &lhs, mp_integer i)
3332
{
3433
return binary_relation_exprt(from_integer(i, lhs.type()), ID_lt, lhs);
3534
}
3635

37-
inline binary_relation_exprt
38-
less_than_or_equal_to(const exprt &lhs, const exprt &rhs)
36+
inline binary_relation_exprt less_than_or_equal_to(exprt lhs, exprt rhs)
3937
{
4038
PRECONDITION(rhs.type() == lhs.type());
41-
return binary_relation_exprt(lhs, ID_le, rhs);
39+
return binary_relation_exprt(std::move(lhs), ID_le, std::move(rhs));
4240
}
4341

4442
inline binary_relation_exprt
@@ -47,10 +45,10 @@ less_than_or_equal_to(const exprt &lhs, mp_integer i)
4745
return binary_relation_exprt(lhs, ID_le, from_integer(i, lhs.type()));
4846
}
4947

50-
inline equal_exprt equal_to(const exprt &lhs, const exprt &rhs)
48+
inline equal_exprt equal_to(exprt lhs, exprt rhs)
5149
{
5250
PRECONDITION(rhs.type() == lhs.type());
53-
return equal_exprt(lhs, rhs);
51+
return equal_exprt(std::move(lhs), std::move(rhs));
5452
}
5553

5654
inline equal_exprt equal_to(const exprt &lhs, mp_integer i)

0 commit comments

Comments
 (0)