Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Feb 21, 2025

@llvm/pr-subscribers-debuginfo

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/128127.diff

1 Files Affected:

  • (modified) llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp (+8-14)
diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
index 82d14861e1e10..67aa71027687a 100644
--- a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
@@ -155,29 +155,23 @@ class LVForwardReferences {
   }
 
   void add(StringRef Name, TypeIndex TIForward) {
-    if (ForwardTypesNames.find(Name) == ForwardTypesNames.end()) {
-      ForwardTypesNames.emplace(
-          std::piecewise_construct, std::forward_as_tuple(Name),
-          std::forward_as_tuple(TIForward, TypeIndex::None()));
-    } else {
+    auto [It, Inserted] =
+        ForwardTypesNames.try_emplace(Name, TIForward, TypeIndex::None());
+    if (!Inserted) {
       // Update a recorded definition with its reference.
-      ForwardTypesNames[Name].first = TIForward;
-      add(TIForward, ForwardTypesNames[Name].second);
+      It->second.first = TIForward;
+      add(TIForward, It->second.second);
     }
   }
 
   // Update a previously recorded forward reference with its definition.
   void update(StringRef Name, TypeIndex TIReference) {
-    auto It = ForwardTypesNames.find(Name);
-    if (It != ForwardTypesNames.end()) {
+    auto [It, Inserted] =
+        ForwardTypesNames.try_emplace(Name, TypeIndex::None(), TIReference);
+    if (!Inserted) {
       // Update the recorded forward reference with its definition.
       It->second.second = TIReference;
       add(It->second.first, TIReference);
-    } else {
-      // We have not seen the forward reference. Insert the definition.
-      ForwardTypesNames.emplace(
-          std::piecewise_construct, std::forward_as_tuple(Name),
-          std::forward_as_tuple(TypeIndex::None(), TIReference));
     }
   }
 

@kazutakahirata kazutakahirata merged commit f964377 into llvm:main Feb 21, 2025
13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_DebugInfo branch February 21, 2025 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants