[llvm] e49c8d5 - [DebugInfo] Avoid repeated map lookups (NFC) (#128826)

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 00:56:06 PST 2025


Author: Kazu Hirata
Date: 2025-02-26T00:56:03-08:00
New Revision: e49c8d5d3d40d184665eae2c5c49df4fa4b7c6cc

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

LOG: [DebugInfo] Avoid repeated map lookups (NFC) (#128826)

Added: 
    

Modified: 
    llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
index 67aa71027687a..97214948d014a 100644
--- a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
@@ -268,10 +268,9 @@ class LVStringRecords {
 
   void add(TypeIndex TI, StringRef String) {
     static uint32_t Index = 0;
-    if (Strings.find(TI) == Strings.end())
-      Strings.emplace(
-          std::piecewise_construct, std::forward_as_tuple(TI),
-          std::forward_as_tuple(++Index, std::string(String), nullptr));
+    auto [It, Inserted] = Strings.try_emplace(TI);
+    if (Inserted)
+      It->second = std::make_tuple(++Index, std::string(String), nullptr);
   }
 
   StringRef find(TypeIndex TI) {


        


More information about the llvm-commits mailing list