[clang] 6444ed5 - [AST] Avoid repeated hash lookups (NFC) (#126400)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 9 08:55:34 PST 2025
Author: Kazu Hirata
Date: 2025-02-09T08:55:31-08:00
New Revision: 6444ed53658354efb8fc126f93281bc13f1d6300
URL: https://github.com/llvm/llvm-project/commit/6444ed53658354efb8fc126f93281bc13f1d6300
DIFF: https://github.com/llvm/llvm-project/commit/6444ed53658354efb8fc126f93281bc13f1d6300.diff
LOG: [AST] Avoid repeated hash lookups (NFC) (#126400)
Added:
Modified:
clang/lib/AST/VTableBuilder.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index fa3055dd1206f41..19d76df99dbe310 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -1169,12 +1169,13 @@ void ItaniumVTableBuilder::ComputeThisAdjustments() {
//
// Do not set ThunkInfo::Method if Idx is already in VTableThunks. This
// can happen when covariant return adjustment is required too.
- if (!VTableThunks.count(Idx)) {
+ auto [It, Inserted] = VTableThunks.try_emplace(Idx);
+ if (Inserted) {
const CXXMethodDecl *Method = VTables.findOriginalMethodInMap(MD);
- VTableThunks[Idx].Method = Method;
- VTableThunks[Idx].ThisType = Method->getThisType().getTypePtr();
+ It->second.Method = Method;
+ It->second.ThisType = Method->getThisType().getTypePtr();
}
- VTableThunks[Idx].This = ThisAdjustment;
+ It->second.This = ThisAdjustment;
};
SetThisAdjustmentThunk(VTableIndex);
@@ -1653,8 +1654,9 @@ void ItaniumVTableBuilder::AddMethods(
// findOriginalMethod to find the method that created the entry if the
// method in the entry requires adjustment.
if (!ReturnAdjustment.isEmpty()) {
- VTableThunks[Components.size()].Method = MD;
- VTableThunks[Components.size()].ThisType = MD->getThisType().getTypePtr();
+ auto &VTT = VTableThunks[Components.size()];
+ VTT.Method = MD;
+ VTT.ThisType = MD->getThisType().getTypePtr();
}
AddMethod(Overrider.Method, ReturnAdjustment);
More information about the cfe-commits
mailing list