Skip to content

Commit 63c32d9

Browse files
Merge pull request #5399 from hannes-steffenhagen-diffblue/refactor/avoid-unnecessary-copy
Refactor/avoid unnecessary copy
2 parents c12016b + 39059d8 commit 63c32d9

File tree

13 files changed

+25
-25
lines changed

13 files changed

+25
-25
lines changed

jbmc/src/java_bytecode/java_types.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ void get_dependencies_from_generic_parameters_rec(
946946
// Java generic type that holds different types in its type arguments
947947
if(is_java_generic_type(t))
948948
{
949-
for(const auto type_arg : to_java_generic_type(t).generic_type_arguments())
949+
for(const auto &type_arg : to_java_generic_type(t).generic_type_arguments())
950950
get_dependencies_from_generic_parameters_rec(type_arg, refs);
951951
}
952952

@@ -1126,7 +1126,7 @@ std::string pretty_signature(const java_method_typet &method_type)
11261126
result << '(';
11271127

11281128
bool first = true;
1129-
for(const auto p : method_type.parameters())
1129+
for(const auto &p : method_type.parameters())
11301130
{
11311131
if(p.get_this())
11321132
continue;

jbmc/unit/java-testing-utils/require_goto_statements.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ require_goto_statements::find_pointer_assignments(
263263
}
264264

265265
std::ostringstream found_symbols;
266-
for(const auto entry : all_symbols)
266+
for(const auto &entry : all_symbols)
267267
{
268268
found_symbols << entry << std::endl;
269269
}

jbmc/unit/java-testing-utils/require_parse_tree.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const require_parse_tree::methodt require_parse_tree::require_method(
6060

6161
INFO("Looking for method: " << method_name);
6262
std::ostringstream found_methods;
63-
for(const auto entry : parsed_class.methods)
63+
for(const auto &entry : parsed_class.methods)
6464
{
6565
found_methods << id2string(entry.name) << std::endl;
6666
}
@@ -80,7 +80,7 @@ void require_parse_tree::require_instructions_match_expectation(
8080
{
8181
REQUIRE(instructions.size() == expected_instructions.size());
8282
auto actual_instruction_it = instructions.begin();
83-
for(const auto expected_instruction : expected_instructions)
83+
for(const auto &expected_instruction : expected_instructions)
8484
{
8585
expected_instruction.require_instructions_equal(*actual_instruction_it);
8686
++actual_instruction_it;

jbmc/unit/java_bytecode/java_bytecode_convert_class/add_java_array_types.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ TEST_CASE("Add array types", "[core]")
2727

2828
SECTION("Array class symbol exists")
2929
{
30-
for(const std::string array_type : array_types)
30+
for(const std::string &array_type : array_types)
3131
{
3232
const auto array_type_symbol = require_symbol::require_symbol_exists(
3333
symbol_table, "java::array[" + array_type + "]");
@@ -38,7 +38,7 @@ TEST_CASE("Add array types", "[core]")
3838
}
3939
SECTION("Array clone method exists")
4040
{
41-
for(const std::string array_type : array_types)
41+
for(const std::string &array_type : array_types)
4242
{
4343
const auto array_type_symbol = require_symbol::require_symbol_exists(
4444
symbol_table,

jbmc/unit/java_bytecode/java_bytecode_convert_method/convert_method.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ TEST_CASE(
938938
other_param.type() = java_lang_object_type();
939939
java_method_typet::parameterst parameters{
940940
this_param, ref_to_inner, other_param};
941-
for(const auto param : parameters)
941+
for(const auto &param : parameters)
942942
{
943943
REQUIRE(param.get_identifier().empty());
944944
REQUIRE(param.get_base_name().empty());

src/cbmc/c_test_input_generator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void c_test_input_generatort::operator()(const goto_trace_storaget &traces)
137137
{
138138
case ui_message_handlert::uit::PLAIN:
139139
log.result() << "\nTest suite:\n";
140-
for(const auto trace : traces.all())
140+
for(const auto &trace : traces.all())
141141
{
142142
test_inputst test_inputs = (*this)(trace, ns);
143143
test_inputs.output_plain_text(log.result(), ns, trace);
@@ -153,15 +153,15 @@ void c_test_input_generatort::operator()(const goto_trace_storaget &traces)
153153
json_stream_arrayt &tests_array =
154154
json_result.push_back_stream_array("tests");
155155

156-
for(const auto trace : traces.all())
156+
for(const auto &trace : traces.all())
157157
{
158158
test_inputst test_inputs = (*this)(trace, ns);
159159
tests_array.push_back(test_inputs.to_json(ns, trace, print_trace));
160160
}
161161
break;
162162
}
163163
case ui_message_handlert::uit::XML_UI:
164-
for(const auto trace : traces.all())
164+
for(const auto &trace : traces.all())
165165
{
166166
test_inputst test_inputs = (*this)(trace, ns);
167167
log.result() << test_inputs.to_xml(ns, trace, print_trace);

src/goto-checker/report_util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ static void output_fault_localization_plain(
473473
messaget &log)
474474
{
475475
log.result() << "\n** Most likely fault location:" << messaget::eom;
476-
for(const auto fault_location_pair : fault_locations)
476+
for(const auto &fault_location_pair : fault_locations)
477477
{
478478
output_fault_localization_plain(
479479
fault_location_pair.first, fault_location_pair.second, log);
@@ -509,7 +509,7 @@ static void output_fault_localization_xml(
509509
messaget &log)
510510
{
511511
xmlt dest("fault-localization");
512-
for(const auto fault_location_pair : fault_locations)
512+
for(const auto &fault_location_pair : fault_locations)
513513
{
514514
xmlt xml_diagnosis =
515515
xml(fault_location_pair.first, fault_location_pair.second, log);

src/goto-diff/unified_diff.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ void unified_difft::output(std::ostream &os) const
368368
{
369369
goto_programt empty;
370370

371-
for(const std::pair<irep_idt, differencest> &p : differences_map_)
371+
for(auto const &p : differences_map_)
372372
{
373373
const irep_idt &function = p.first;
374374

src/goto-instrument/count_eloc.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ void count_eloc(const goto_modelt &goto_model)
5454
working_dirst eloc_map;
5555
collect_eloc(goto_model, eloc_map);
5656

57-
for(const std::pair<irep_idt, filest> &files : eloc_map)
58-
for(const std::pair<irep_idt, linest> &lines : files.second)
57+
for(auto const &files : eloc_map)
58+
for(auto const &lines : files.second)
5959
eloc+=lines.second.size();
6060

6161
std::cout << "Effective lines of code: " << eloc << '\n';
@@ -66,8 +66,8 @@ void list_eloc(const goto_modelt &goto_model)
6666
working_dirst eloc_map;
6767
collect_eloc(goto_model, eloc_map);
6868

69-
for(const std::pair<irep_idt, filest> &files : eloc_map)
70-
for(const std::pair<irep_idt, linest> &lines : files.second)
69+
for(auto const &files : eloc_map)
70+
for(auto const &lines : files.second)
7171
{
7272
std::string file=id2string(lines.first);
7373
if(!files.first.empty())

src/langapi/language_file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class language_filest:public messaget
8484
// Clear relevant entries from lazy_method_map
8585
language_filet *language_file = &file_map.at(filename);
8686
std::unordered_set<irep_idt> files_methods;
87-
for(const std::pair<irep_idt, language_filet *> &method : lazy_method_map)
87+
for(auto const &method : lazy_method_map)
8888
{
8989
if(method.second == language_file)
9090
files_methods.insert(method.first);

0 commit comments

Comments
 (0)