Skip to content

Commit

Permalink
[AST] Avoid repeated hash lookups (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Feb 9, 2025
1 parent 7c60725 commit b070c73
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions clang/lib/AST/VTableBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b070c73

Please sign in to comment.