Skip to content

Commit fda9daa

Browse files
Cleanup of create-and-swap to emplace
1 parent eb5ec24 commit fda9daa

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/goto-programs/link_goto_model.cpp

+4-11
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,15 @@ static bool link_functions(
6969
goto_functionst::function_mapt::iterator dest_f_it=
7070
dest_functions.function_map.find(final_id);
7171

72+
goto_functionst::goto_functiont &src_func = src_it->second;
7273
if(dest_f_it==dest_functions.function_map.end()) // not there yet
7374
{
74-
rename_symbols_in_function(src_it->second, final_id, rename_symbol);
75-
76-
goto_functionst::goto_functiont &in_dest_symbol_table=
77-
dest_functions.function_map[final_id];
78-
79-
in_dest_symbol_table.body.swap(src_it->second.body);
80-
in_dest_symbol_table.type=src_it->second.type;
75+
rename_symbols_in_function(src_func, final_id, rename_symbol);
76+
dest_functions.function_map.emplace(final_id, std::move(src_func));
8177
}
8278
else // collision!
8379
{
84-
goto_functionst::goto_functiont &in_dest_symbol_table=
85-
dest_functions.function_map[final_id];
86-
87-
goto_functionst::goto_functiont &src_func=src_it->second;
80+
goto_functionst::goto_functiont &in_dest_symbol_table = dest_f_it->second;
8881

8982
if(in_dest_symbol_table.body.instructions.empty() ||
9083
weak_symbols.find(final_id)!=weak_symbols.end())

0 commit comments

Comments
 (0)