Skip to content

Commit 8a53dc6

Browse files
[DebugInfo] Avoid repeated map lookups (NFC) (#111936)
1 parent eef6c09 commit 8a53dc6

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,11 @@ class LVForwardReferences {
173173

174174
// Update a previously recorded forward reference with its definition.
175175
void update(StringRef Name, TypeIndex TIReference) {
176-
if (ForwardTypesNames.find(Name) != ForwardTypesNames.end()) {
176+
auto It = ForwardTypesNames.find(Name);
177+
if (It != ForwardTypesNames.end()) {
177178
// Update the recorded forward reference with its definition.
178-
ForwardTypesNames[Name].second = TIReference;
179-
add(ForwardTypesNames[Name].first, TIReference);
179+
It->second.second = TIReference;
180+
add(It->second.first, TIReference);
180181
} else {
181182
// We have not seen the forward reference. Insert the definition.
182183
ForwardTypesNames.emplace(
@@ -196,15 +197,14 @@ class LVForwardReferences {
196197
}
197198

198199
TypeIndex find(TypeIndex TIForward) {
199-
return (ForwardTypes.find(TIForward) != ForwardTypes.end())
200-
? ForwardTypes[TIForward]
201-
: TypeIndex::None();
200+
auto It = ForwardTypes.find(TIForward);
201+
return It != ForwardTypes.end() ? It->second : TypeIndex::None();
202202
}
203203

204204
TypeIndex find(StringRef Name) {
205-
return (ForwardTypesNames.find(Name) != ForwardTypesNames.end())
206-
? ForwardTypesNames[Name].second
207-
: TypeIndex::None();
205+
auto It = ForwardTypesNames.find(Name);
206+
return It != ForwardTypesNames.end() ? It->second.second
207+
: TypeIndex::None();
208208
}
209209

210210
// If the given TI corresponds to a reference, return the reference.
@@ -242,9 +242,8 @@ class LVNamespaceDeduction {
242242

243243
// Find the logical namespace for the 'Name' component.
244244
LVScope *find(StringRef Name) {
245-
LVScope *Namespace = (NamespaceNames.find(Name) != NamespaceNames.end())
246-
? NamespaceNames[Name]
247-
: nullptr;
245+
auto It = NamespaceNames.find(Name);
246+
LVScope *Namespace = It != NamespaceNames.end() ? It->second : nullptr;
248247
return Namespace;
249248
}
250249

0 commit comments

Comments
 (0)