[llvm] [MC] Avoid repeated hash lookups (NFC) (PR #110791)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 1 21:26:57 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/110791

None

>From 1efad6c5b75649c879c5ed31516a2011972ccbf1 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 1 Oct 2024 07:51:05 -0700
Subject: [PATCH] [MC] Avoid repeated hash lookups (NFC)

---
 llvm/lib/MC/XCOFFObjectWriter.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp
index 124b31e8708842..c7f29c73eaac09 100644
--- a/llvm/lib/MC/XCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -666,8 +666,9 @@ void XCOFFObjectWriter::recordRelocation(MCAssembler &Asm,
     // If we could not find the symbol directly in SymbolIndexMap, this symbol
     // could either be a temporary symbol or an undefined symbol. In this case,
     // we would need to have the relocation reference its csect instead.
-    return SymbolIndexMap.contains(Sym)
-               ? SymbolIndexMap[Sym]
+    auto It = SymbolIndexMap.find(Sym);
+    return It != SymbolIndexMap.end()
+               ? It->second
                : SymbolIndexMap[ContainingCsect->getQualNameSymbol()];
   };
 



More information about the llvm-commits mailing list