@@ -16,7 +16,7 @@ Author: Daniel Kroening, kroening@kroening.com
1616// / get all functions whose address is taken
1717void compute_address_taken_functions (
1818 const exprt &src,
19- std::set <irep_idt> &address_taken)
19+ std::unordered_set <irep_idt> &address_taken)
2020{
2121 forall_operands (it, src)
2222 compute_address_taken_functions (*it, address_taken);
@@ -35,7 +35,7 @@ void compute_address_taken_functions(
3535// / get all functions in the expression
3636void compute_functions (
3737 const exprt &src,
38- std::set <irep_idt> &address_taken)
38+ std::unordered_set <irep_idt> &address_taken)
3939{
4040 forall_operands (it, src)
4141 compute_functions (*it, address_taken);
@@ -48,7 +48,7 @@ void compute_functions(
4848// / get all functions whose address is taken
4949void compute_address_taken_functions (
5050 const goto_programt &goto_program,
51- std::set <irep_idt> &address_taken)
51+ std::unordered_set <irep_idt> &address_taken)
5252{
5353 forall_goto_program_instructions (it, goto_program)
5454 {
@@ -60,28 +60,27 @@ void compute_address_taken_functions(
6060// / get all functions whose address is taken
6161void compute_address_taken_functions (
6262 const goto_functionst &goto_functions,
63- std::set <irep_idt> &address_taken)
63+ std::unordered_set <irep_idt> &address_taken)
6464{
6565 forall_goto_functions (it, goto_functions)
6666 compute_address_taken_functions (it->second .body , address_taken);
6767}
6868
6969// / get all functions whose address is taken
70- std::set <irep_idt> compute_address_taken_functions (
71- const goto_functionst &goto_functions)
70+ std::unordered_set <irep_idt>
71+ compute_address_taken_functions ( const goto_functionst &goto_functions)
7272{
73- std::set <irep_idt> address_taken;
73+ std::unordered_set <irep_idt> address_taken;
7474 compute_address_taken_functions (goto_functions, address_taken);
7575 return address_taken;
7676}
7777
7878// / computes the functions that are (potentially) called
79- std::set <irep_idt> compute_called_functions (
80- const goto_functionst &goto_functions)
79+ std::unordered_set <irep_idt>
80+ compute_called_functions ( const goto_functionst &goto_functions)
8181{
82- std::set<irep_idt> working_queue;
83- std::set<irep_idt> done;
84- std::set<irep_idt> functions;
82+ std::unordered_set<irep_idt> working_queue;
83+ std::unordered_set<irep_idt> functions;
8584
8685 // start from entry point
8786 working_queue.insert (goto_functions.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
@@ -123,8 +119,8 @@ std::set<irep_idt> compute_called_functions(
123119}
124120
125121// / computes the functions that are (potentially) called
126- std::set <irep_idt> compute_called_functions (
127- const goto_modelt &goto_model)
122+ std::unordered_set <irep_idt>
123+ compute_called_functions ( const goto_modelt &goto_model)
128124{
129125 return compute_called_functions (goto_model.goto_functions );
130126}
0 commit comments