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

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 06:54:28 PDT 2024


Author: Kazu Hirata
Date: 2024-10-02T06:54:24-07:00
New Revision: edfb6dd3f7f9a5408dd382805bb8d704f6eb3d31

URL: https://github.com/llvm/llvm-project/commit/edfb6dd3f7f9a5408dd382805bb8d704f6eb3d31
DIFF: https://github.com/llvm/llvm-project/commit/edfb6dd3f7f9a5408dd382805bb8d704f6eb3d31.diff

LOG: [MC] Avoid repeated hash lookups (NFC) (#110791)

Added: 
    

Modified: 
    llvm/lib/MC/XCOFFObjectWriter.cpp

Removed: 
    


################################################################################
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