Skip to content

Commit 11c6ea3

Browse files
[ExecutionEngine] Avoid repeated hash lookups (NFC) (#111275)
1 parent 93f7fce commit 11c6ea3

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,13 +1610,10 @@ RuntimeDyldELF::processRelocationRef(
16101610
RelocationEntry RE(SectionID, Offset, RelType, Value.Addend);
16111611
if (r_type == ELF::R_MIPS_CALL16 || r_type == ELF::R_MIPS_GOT_PAGE
16121612
|| r_type == ELF::R_MIPS_GOT_DISP) {
1613-
StringMap<uint64_t>::iterator i = GOTSymbolOffsets.find(TargetName);
1614-
if (i != GOTSymbolOffsets.end())
1615-
RE.SymOffset = i->second;
1616-
else {
1617-
RE.SymOffset = allocateGOTEntries(1);
1618-
GOTSymbolOffsets[TargetName] = RE.SymOffset;
1619-
}
1613+
auto [I, Inserted] = GOTSymbolOffsets.try_emplace(TargetName);
1614+
if (Inserted)
1615+
I->second = allocateGOTEntries(1);
1616+
RE.SymOffset = I->second;
16201617
if (Value.SymbolName)
16211618
addRelocationForSymbol(RE, Value.SymbolName);
16221619
else

0 commit comments

Comments
 (0)