Skip to content

Commit 25d765b

Browse files
author
thk123
committed
Use a for loop rather than chained algorithms
1 parent e67d229 commit 25d765b

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

unit/testing-utils/require_goto_statements.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,15 @@ std::vector<codet>
2020
require_goto_statements::get_all_statements(const exprt &function_value)
2121
{
2222
std::vector<codet> statements;
23-
24-
// Add any child statements (e.g. if this is a code_block
25-
// TODO(tkiley): It should be possible to have a custom version of
26-
// TODO(tkiley): back_inserter that also transforms to codet, but I don't
27-
// TODO(tkiley): know how to do this
28-
std::vector<exprt> sub_expr;
29-
std::copy_if(
30-
function_value.depth_begin(),
31-
function_value.depth_end(),
32-
std::back_inserter(sub_expr),
33-
[](const exprt &sub_statement) {
34-
// Get all codet
35-
return sub_statement.id() == ID_code;
36-
});
37-
38-
std::transform(
39-
sub_expr.begin(),
40-
sub_expr.end(),
41-
std::back_inserter(statements),
42-
[](const exprt &sub_expr) { return to_code(sub_expr); });
23+
for(auto sub_expression_it = function_value.depth_begin();
24+
sub_expression_it != function_value.depth_end();
25+
++sub_expression_it)
26+
{
27+
if(sub_expression_it->id() == ID_code)
28+
{
29+
statements.push_back(to_code(*sub_expression_it));
30+
}
31+
}
4332

4433
return statements;
4534
}

0 commit comments

Comments
 (0)