[llvm] [DebugInfo] Avoid repeated map lookups (NFC) (PR #111936)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 20:40:27 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/111936
None
>From 23c980930f5c3ffce416d9c2f9a1d64319ecd1ea Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 10 Oct 2024 08:27:54 -0700
Subject: [PATCH] [DebugInfo] Avoid repeated map lookups (NFC)
---
.../LogicalView/Readers/LVCodeViewVisitor.cpp | 23 +++++++++----------
1 file changed, 11 insertions(+), 12 deletions(-)
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;
}
More information about the llvm-commits
mailing list