Skip to content

Commit 54f0010

Browse files
Avoid unnecessary copy in count_eloc.cpp
There is a type mismatch here: the maps contain `std::pair<const irep_idt, T>` (note the const). This forces the compiler to make copies despite the reference tag. Using auto instead fixes this instance and generally reduces the potential for making similar mistakes.
1 parent 388815c commit 54f0010

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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())

0 commit comments

Comments
 (0)