Skip to content

Commit 5c01d54

Browse files
authored
Simplify lookup table cleanup code. No functionality change. (#7724)
No need to bounce through another function just to call a destructor.
1 parent 4392a10 commit 5c01d54

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

lib/AST/NameLookup.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -980,9 +980,6 @@ class swift::MemberLookupTable {
980980
/// Create a new member lookup table.
981981
explicit MemberLookupTable(ASTContext &ctx);
982982

983-
/// Destroy the lookup table.
984-
void destroy();
985-
986983
/// Update a lookup table with members from newly-added extensions.
987984
void updateLookupTable(NominalTypeDecl *nominal);
988985

@@ -1039,10 +1036,6 @@ class ClassDecl::ObjCMethodLookupTable
10391036
StoredObjCMethods>
10401037
{
10411038
public:
1042-
void destroy() {
1043-
this->~ObjCMethodLookupTable();
1044-
}
1045-
10461039
// Only allow allocation of member lookup tables using the allocator in
10471040
// ASTContext or by doing a placement new.
10481041
void *operator new(size_t Bytes, ASTContext &C,
@@ -1059,7 +1052,7 @@ MemberLookupTable::MemberLookupTable(ASTContext &ctx) {
10591052
// Register a cleanup with the ASTContext to call the lookup table
10601053
// destructor.
10611054
ctx.addCleanup([this]() {
1062-
this->destroy();
1055+
this->~MemberLookupTable();
10631056
});
10641057
}
10651058

@@ -1127,10 +1120,6 @@ void MemberLookupTable::updateLookupTable(NominalTypeDecl *nominal) {
11271120
}
11281121
}
11291122

1130-
void MemberLookupTable::destroy() {
1131-
this->~MemberLookupTable();
1132-
}
1133-
11341123
void NominalTypeDecl::addedMember(Decl *member) {
11351124
// If we have a lookup table, add the new member to it.
11361125
if (LookupTable.getPointer()) {
@@ -1218,7 +1207,7 @@ void ClassDecl::createObjCMethodLookup() {
12181207
// Register a cleanup with the ASTContext to call the lookup table
12191208
// destructor.
12201209
ctx.addCleanup([this]() {
1221-
this->ObjCMethodLookup->destroy();
1210+
this->ObjCMethodLookup->~ObjCMethodLookupTable();
12221211
});
12231212
}
12241213

0 commit comments

Comments
 (0)