Skip to content

[DebugInfo] Avoid repeated map lookups (NFC) #111936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down
Loading