From 7c930fda899c5bb1a89d29afd3590dffe726b737 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 4 Mar 2025 07:31:17 -0800 Subject: [PATCH] [ExecutionEngine] Avoid repeated hash lookups (NFC) --- llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp index 8ceb08051e423..30718bae15565 100644 --- a/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp @@ -235,12 +235,12 @@ class COFFLinkGraphLowering_x86_64 { private: orc::ExecutorAddr getSectionStart(Section &Sec) { - if (!SectionStartCache.count(&Sec)) { + auto [It, Inserted] = SectionStartCache.try_emplace(&Sec); + if (Inserted) { SectionRange Range(Sec); - SectionStartCache[&Sec] = Range.getStart(); - return Range.getStart(); + It->second = Range.getStart(); } - return SectionStartCache[&Sec]; + return It->second; } GetImageBaseSymbol GetImageBase;