[llvm] f964377 - [DebugInfo] Avoid repeated hash lookups (NFC) (#128127)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 21 11:07:54 PST 2025
Author: Kazu Hirata
Date: 2025-02-21T11:07:51-08:00
New Revision: f964377df76f9ba3ee025fdae4620f79fb81e809
URL: https://github.com/llvm/llvm-project/commit/f964377df76f9ba3ee025fdae4620f79fb81e809
DIFF: https://github.com/llvm/llvm-project/commit/f964377df76f9ba3ee025fdae4620f79fb81e809.diff
LOG: [DebugInfo] Avoid repeated hash lookups (NFC) (#128127)
Added:
Modified:
llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
Removed:
################################################################################
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));
}
}
More information about the llvm-commits
mailing list