@@ -24,18 +24,16 @@ using namespace llvm::logicalview;
24
24
void LVSymbolTable::add (StringRef Name, LVScope *Function,
25
25
LVSectionIndex SectionIndex) {
26
26
std::string SymbolName (Name);
27
- if (SymbolNames.find (SymbolName) == SymbolNames.end ()) {
28
- SymbolNames.emplace (
29
- std::piecewise_construct, std::forward_as_tuple (SymbolName),
30
- std::forward_as_tuple (Function, 0 , SectionIndex, false ));
31
- } else {
27
+ auto [It, Inserted] =
28
+ SymbolNames.try_emplace (SymbolName, Function, 0 , SectionIndex, false );
29
+ if (!Inserted) {
32
30
// Update a recorded entry with its logical scope and section index.
33
- SymbolNames[SymbolName] .Scope = Function;
31
+ It-> second .Scope = Function;
34
32
if (SectionIndex)
35
- SymbolNames[SymbolName] .SectionIndex = SectionIndex;
33
+ It-> second .SectionIndex = SectionIndex;
36
34
}
37
35
38
- if (Function && SymbolNames[SymbolName] .IsComdat )
36
+ if (Function && It-> second .IsComdat )
39
37
Function->setIsComdat ();
40
38
41
39
LLVM_DEBUG ({ print (dbgs ()); });
@@ -44,15 +42,13 @@ void LVSymbolTable::add(StringRef Name, LVScope *Function,
44
42
void LVSymbolTable::add (StringRef Name, LVAddress Address,
45
43
LVSectionIndex SectionIndex, bool IsComdat) {
46
44
std::string SymbolName (Name);
47
- if (SymbolNames.find (SymbolName) == SymbolNames.end ())
48
- SymbolNames.emplace (
49
- std::piecewise_construct, std::forward_as_tuple (SymbolName),
50
- std::forward_as_tuple (nullptr , Address, SectionIndex, IsComdat));
51
- else
45
+ auto [It, Inserted] = SymbolNames.try_emplace (SymbolName, nullptr , Address,
46
+ SectionIndex, IsComdat);
47
+ if (!Inserted)
52
48
// Update a recorded symbol name with its logical scope.
53
- SymbolNames[SymbolName] .Address = Address;
49
+ It-> second .Address = Address;
54
50
55
- LVScope *Function = SymbolNames[SymbolName] .Scope ;
51
+ LVScope *Function = It-> second .Scope ;
56
52
if (Function && IsComdat)
57
53
Function->setIsComdat ();
58
54
LLVM_DEBUG ({ print (dbgs ()); });
0 commit comments