[llvm] [DebugInfo] Avoid repeated map lookups (NFC) (PR #111936)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 20:40:59 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/111936.diff
1 Files Affected:
- (modified) llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp (+11-12)
``````````diff
diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
index e89664d360a9a2..a15f9cd8597679 100644
--- a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
@@ -173,10 +173,11 @@ class LVForwardReferences {
// Update a previously recorded forward reference with its definition.
void update(StringRef Name, TypeIndex TIReference) {
- if (ForwardTypesNames.find(Name) != ForwardTypesNames.end()) {
+ auto It = ForwardTypesNames.find(Name);
+ if (It != ForwardTypesNames.end()) {
// Update the recorded forward reference with its definition.
- ForwardTypesNames[Name].second = TIReference;
- add(ForwardTypesNames[Name].first, TIReference);
+ It->second.second = TIReference;
+ add(It->second.first, TIReference);
} else {
// We have not seen the forward reference. Insert the definition.
ForwardTypesNames.emplace(
@@ -196,15 +197,14 @@ class LVForwardReferences {
}
TypeIndex find(TypeIndex TIForward) {
- return (ForwardTypes.find(TIForward) != ForwardTypes.end())
- ? ForwardTypes[TIForward]
- : TypeIndex::None();
+ auto It = ForwardTypes.find(TIForward);
+ return It != ForwardTypes.end() ? It->second : TypeIndex::None();
}
TypeIndex find(StringRef Name) {
- return (ForwardTypesNames.find(Name) != ForwardTypesNames.end())
- ? ForwardTypesNames[Name].second
- : TypeIndex::None();
+ auto It = ForwardTypesNames.find(Name);
+ return It != ForwardTypesNames.end() ? It->second.second
+ : TypeIndex::None();
}
// If the given TI corresponds to a reference, return the reference.
@@ -242,9 +242,8 @@ class LVNamespaceDeduction {
// Find the logical namespace for the 'Name' component.
LVScope *find(StringRef Name) {
- LVScope *Namespace = (NamespaceNames.find(Name) != NamespaceNames.end())
- ? NamespaceNames[Name]
- : nullptr;
+ auto It = NamespaceNames.find(Name);
+ LVScope *Namespace = It != NamespaceNames.end() ? It->second : nullptr;
return Namespace;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/111936
More information about the llvm-commits
mailing list