[lld] 3c2e1d3 - [lld] Avoid repeated hash lookups (NFC) (#112299)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 15 07:35:46 PDT 2024


Author: Kazu Hirata
Date: 2024-10-15T07:35:42-07:00
New Revision: 3c2e1d3a0014f3d659c29f1defce0674f6f755c0

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

LOG: [lld] Avoid repeated hash lookups (NFC) (#112299)

Added: 
    

Modified: 
    lld/COFF/SymbolTable.cpp

Removed: 
    


################################################################################
diff  --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp
index 3bd471389daa1f..fa09ea64babb28 100644
--- a/lld/COFF/SymbolTable.cpp
+++ b/lld/COFF/SymbolTable.cpp
@@ -424,13 +424,11 @@ static void reportProblemSymbols(
       if (!sym)
         continue;
       if (undefs.count(sym)) {
-        auto it = firstDiag.find(sym);
-        if (it == firstDiag.end()) {
-          firstDiag[sym] = undefDiags.size();
+        auto [it, inserted] = firstDiag.try_emplace(sym, undefDiags.size());
+        if (inserted)
           undefDiags.push_back({sym, {{file, symIndex}}});
-        } else {
+        else
           undefDiags[it->second].files.push_back({file, symIndex});
-        }
       }
       if (localImports)
         if (Symbol *imp = localImports->lookup(sym))


        


More information about the llvm-commits mailing list