[lld] 16aa400 - [ELF] Avoid repeated hash lookups (NFC) (#122628)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 12 11:07:11 PST 2025


Author: Kazu Hirata
Date: 2025-01-12T11:07:07-08:00
New Revision: 16aa400a2780ab21f73722875734440643f276c3

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

LOG: [ELF] Avoid repeated hash lookups (NFC) (#122628)

Added: 
    

Modified: 
    lld/ELF/Arch/ARM.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Arch/ARM.cpp b/lld/ELF/Arch/ARM.cpp
index 29a72d35af6669..de6e45c6cc65c6 100644
--- a/lld/ELF/Arch/ARM.cpp
+++ b/lld/ELF/Arch/ARM.cpp
@@ -1320,8 +1320,9 @@ void elf::processArmCmseSymbols(Ctx &ctx) {
     MutableArrayRef<Symbol *> syms = file->getMutableSymbols();
     for (size_t i = 0, e = syms.size(); i != e; ++i) {
       StringRef symName = syms[i]->getName();
-      if (ctx.symtab->cmseSymMap.count(symName))
-        syms[i] = ctx.symtab->cmseSymMap[symName].acleSeSym;
+      auto it = ctx.symtab->cmseSymMap.find(symName);
+      if (it != ctx.symtab->cmseSymMap.end())
+        syms[i] = it->second.acleSeSym;
     }
   });
 }
@@ -1370,8 +1371,9 @@ void ArmCmseSGSection::addSGVeneer(Symbol *acleSeSym, Symbol *sym) {
   // Only secure symbols with values equal to that of it's non-secure
   // counterpart needs to be in the .gnu.sgstubs section.
   std::unique_ptr<ArmCmseSGVeneer> ss;
-  if (ctx.symtab->cmseImportLib.count(sym->getName())) {
-    Defined *impSym = ctx.symtab->cmseImportLib[sym->getName()];
+  auto it = ctx.symtab->cmseImportLib.find(sym->getName());
+  if (it != ctx.symtab->cmseImportLib.end()) {
+    Defined *impSym = it->second;
     ss = std::make_unique<ArmCmseSGVeneer>(sym, acleSeSym, impSym->value);
   } else {
     ss = std::make_unique<ArmCmseSGVeneer>(sym, acleSeSym);


        


More information about the llvm-commits mailing list