Skip to content

Commit 026e93f

Browse files
committed
function-pointer-removal: drop unused set
The compute_called_functions method maintains two sets, 'done' and 'functions'. The set 'done' is only used to determine whether an element can be skipped. Since the content of the two sets is the same, the set 'done' can be dropped, and 'functions' can be used instead. Hence, this commit drops the set 'done'. Furthermore, the return value of insert includes a bool that indicates the success of the insert operation. In case insertion failed, the element has been present already, so that we can merge the find+insert into a single insert operation. Fixes: diffblue#1783
1 parent 0f9c202 commit 026e93f

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/goto-programs/compute_called_functions.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ std::set<irep_idt> compute_called_functions(
8080
const goto_functionst &goto_functions)
8181
{
8282
std::set<irep_idt> working_queue;
83-
std::set<irep_idt> done;
8483
std::set<irep_idt> functions;
8584

8685
// start from entry point
@@ -91,12 +90,9 @@ std::set<irep_idt> compute_called_functions(
9190
irep_idt id=*working_queue.begin();
9291
working_queue.erase(working_queue.begin());
9392

94-
if(done.find(id)!=done.end())
93+
if(!functions.insert(id).second)
9594
continue;
9695

97-
functions.insert(id);
98-
done.insert(id);
99-
10096
const goto_functionst::function_mapt::const_iterator f_it=
10197
goto_functions.function_map.find(id);
10298

0 commit comments

Comments
 (0)