From 0c1eea87e4726fbd72ad3664ae49244fdae8125e Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 5 Oct 2024 10:30:06 -0700 Subject: [PATCH] [ExecutionEngine] Avoid repeated hash lookups (NFC) --- .../ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index 92f37c22ae513..25b76c7668350 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -1610,13 +1610,10 @@ RuntimeDyldELF::processRelocationRef( RelocationEntry RE(SectionID, Offset, RelType, Value.Addend); if (r_type == ELF::R_MIPS_CALL16 || r_type == ELF::R_MIPS_GOT_PAGE || r_type == ELF::R_MIPS_GOT_DISP) { - StringMap::iterator i = GOTSymbolOffsets.find(TargetName); - if (i != GOTSymbolOffsets.end()) - RE.SymOffset = i->second; - else { - RE.SymOffset = allocateGOTEntries(1); - GOTSymbolOffsets[TargetName] = RE.SymOffset; - } + auto [I, Inserted] = GOTSymbolOffsets.try_emplace(TargetName); + if (Inserted) + I->second = allocateGOTEntries(1); + RE.SymOffset = I->second; if (Value.SymbolName) addRelocationForSymbol(RE, Value.SymbolName); else