Skip to content

Commit 6444ed5

Browse files
[AST] Avoid repeated hash lookups (NFC) (#126400)
1 parent ed9107f commit 6444ed5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

clang/lib/AST/VTableBuilder.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,12 +1169,13 @@ void ItaniumVTableBuilder::ComputeThisAdjustments() {
11691169
//
11701170
// Do not set ThunkInfo::Method if Idx is already in VTableThunks. This
11711171
// can happen when covariant return adjustment is required too.
1172-
if (!VTableThunks.count(Idx)) {
1172+
auto [It, Inserted] = VTableThunks.try_emplace(Idx);
1173+
if (Inserted) {
11731174
const CXXMethodDecl *Method = VTables.findOriginalMethodInMap(MD);
1174-
VTableThunks[Idx].Method = Method;
1175-
VTableThunks[Idx].ThisType = Method->getThisType().getTypePtr();
1175+
It->second.Method = Method;
1176+
It->second.ThisType = Method->getThisType().getTypePtr();
11761177
}
1177-
VTableThunks[Idx].This = ThisAdjustment;
1178+
It->second.This = ThisAdjustment;
11781179
};
11791180

11801181
SetThisAdjustmentThunk(VTableIndex);
@@ -1653,8 +1654,9 @@ void ItaniumVTableBuilder::AddMethods(
16531654
// findOriginalMethod to find the method that created the entry if the
16541655
// method in the entry requires adjustment.
16551656
if (!ReturnAdjustment.isEmpty()) {
1656-
VTableThunks[Components.size()].Method = MD;
1657-
VTableThunks[Components.size()].ThisType = MD->getThisType().getTypePtr();
1657+
auto &VTT = VTableThunks[Components.size()];
1658+
VTT.Method = MD;
1659+
VTT.ThisType = MD->getThisType().getTypePtr();
16581660
}
16591661

16601662
AddMethod(Overrider.Method, ReturnAdjustment);

0 commit comments

Comments
 (0)