Skip to content

Commit d4e89fd

Browse files
Tidy up symbol_tablet::move
Added comment Move rather than copy empty symbol into table
1 parent 281e384 commit d4e89fd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/util/symbol_table.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,23 @@ bool symbol_tablet::add(const symbolt &symbol)
4545
/// location in the symbol table
4646
bool symbol_tablet::move(symbolt &symbol, symbolt *&new_symbol)
4747
{
48-
symbolt tmp;
49-
48+
// Add an empty symbol to the table or retrieve existing symbol with same name
5049
std::pair<symbolst::iterator, bool> result=
51-
symbols.insert(std::pair<irep_idt, symbolt>(symbol.name, tmp));
50+
symbols.emplace(symbol.name, symbolt());
5251

5352
if(!result.second)
5453
{
54+
// Return the address of the symbol that already existed in the table
5555
new_symbol=&result.first->second;
5656
return true;
5757
}
5858

59-
symbol_base_map.insert(
60-
std::pair<irep_idt, irep_idt>(symbol.base_name, symbol.name));
61-
symbol_module_map.insert(
62-
std::pair<irep_idt, irep_idt>(symbol.module, symbol.name));
59+
symbol_base_map.emplace(symbol.base_name, symbol.name);
60+
symbol_module_map.emplace(symbol.module, symbol.name);
6361

62+
// Move the provided symbol into the symbol table
6463
result.first->second.swap(symbol);
64+
// Return the address of the new symbol in the table
6565
new_symbol=&result.first->second;
6666

6767
return false;

0 commit comments

Comments
 (0)