Skip to content

Commit d1700cd

Browse files
[ExecutionEngine] Avoid repeated hash lookups (NFC) (#131423)
1 parent 6a1fd24 commit d1700cd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,17 @@ uint64_t RuntimeDyldCOFF::getDLLImportOffset(unsigned SectionID, StubMap &Stubs,
8686
"Not a DLLImport symbol?");
8787
RelocationValueRef Reloc;
8888
Reloc.SymbolName = Name.data();
89-
auto I = Stubs.find(Reloc);
90-
if (I != Stubs.end()) {
91-
LLVM_DEBUG(dbgs() << format("{0:x8}", I->second) << "\n");
92-
return I->second;
89+
auto [It, Inserted] = Stubs.try_emplace(Reloc);
90+
if (!Inserted) {
91+
LLVM_DEBUG(dbgs() << format("{0:x8}", It->second) << "\n");
92+
return It->second;
9393
}
9494

9595
assert(SectionID < Sections.size() && "SectionID out of range");
9696
auto &Sec = Sections[SectionID];
9797
auto EntryOffset = alignTo(Sec.getStubOffset(), PointerSize);
9898
Sec.advanceStubOffset(EntryOffset + PointerSize - Sec.getStubOffset());
99-
Stubs[Reloc] = EntryOffset;
99+
It->second = EntryOffset;
100100

101101
RelocationEntry RE(SectionID, EntryOffset, PointerReloc, 0, false,
102102
Log2_64(PointerSize));

0 commit comments

Comments
 (0)