[llvm] 55dd29c - [llvm-profdata] Avoid repeated hash lookups (NFC) (#111629)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 8 23:02:07 PDT 2024


Author: Kazu Hirata
Date: 2024-10-08T23:02:04-07:00
New Revision: 55dd29c61d1bd5509504ef0c6014b3879567eb17

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

LOG: [llvm-profdata] Avoid repeated hash lookups (NFC) (#111629)

Added: 
    

Modified: 
    llvm/tools/llvm-profdata/llvm-profdata.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 8a36726769f221..17933e4500ead6 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -1220,11 +1220,9 @@ adjustInstrProfile(std::unique_ptr<WriterContext> &WC,
       }
     }
 
-    if (!StaticFuncMap.contains(NewName)) {
-      StaticFuncMap[NewName] = Name;
-    } else {
-      StaticFuncMap[NewName] = DuplicateNameStr;
-    }
+    auto [It, Inserted] = StaticFuncMap.try_emplace(NewName, Name);
+    if (!Inserted)
+      It->second = DuplicateNameStr;
   };
 
   // We need to flatten the SampleFDO profile as the InstrFDO


        


More information about the llvm-commits mailing list