Skip to content

Commit 046e9b1

Browse files
Improve map_representation_of_sum code
Fix typo, avoid double lookup and improve example in the documentation.
1 parent 165f29d commit 046e9b1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/solvers/strings/string_constraint_instantiation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ find_indexes(const exprt &expr, const exprt &str, const symbol_exprt &qvar)
5252

5353
std::map<exprt, int> map_representation_of_sum(const exprt &f)
5454
{
55-
// number of time the leaf should be added (can be negative)
55+
// number of times the leaf should be added (can be negative)
5656
std::map<exprt, int> elems;
5757

5858
std::list<std::pair<exprt, bool>> to_process;
@@ -80,9 +80,9 @@ std::map<exprt, int> map_representation_of_sum(const exprt &f)
8080
else
8181
{
8282
if(positive)
83-
elems[cur] = elems[cur] + 1;
83+
++elems[cur];
8484
else
85-
elems[cur] = elems[cur] - 1;
85+
--elems[cur];
8686
}
8787
}
8888
return elems;

src/solvers/strings/string_constraint_instantiation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ std::vector<exprt> instantiate_not_contains(
3737

3838
/// \param f: an expression with only addition and subtraction
3939
/// \return a map where each leaf of the input is mapped to the number of times
40-
/// it is added. For instance, expression $x + x - y$ would give the map x ->
41-
/// 2, y -> -1.
40+
/// it is added. For instance, expression $x + x - y + 3 - 5$ would give the
41+
/// map x -> 2, y -> -1, 3 -> 1, 5 -> -1.
4242
std::map<exprt, int> map_representation_of_sum(const exprt &f);
4343

4444
/// \param m: a map from expressions to integers

0 commit comments

Comments
 (0)