Skip to content

Commit 6d9a8bf

Browse files
committed
[AST] NFC: Simplify BoundGenericType::Profile
BoundGenericType::Profile() is the only Profile method that calculates the recursive type properties as a side effect. This change makes the method like all of the others.
1 parent 8a62b66 commit 6d9a8bf

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

include/swift/AST/Types.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,12 +1716,10 @@ class BoundGenericType : public TypeBase, public llvm::FoldingSetNode {
17161716
ArrayRef<Type> getGenericArgs() const { return GenericArgs; }
17171717

17181718
void Profile(llvm::FoldingSetNodeID &ID) {
1719-
RecursiveTypeProperties properties;
1720-
Profile(ID, TheDecl, Parent, GenericArgs, properties);
1719+
Profile(ID, TheDecl, Parent, GenericArgs);
17211720
}
17221721
static void Profile(llvm::FoldingSetNodeID &ID, NominalTypeDecl *TheDecl,
1723-
Type Parent, ArrayRef<Type> GenericArgs,
1724-
RecursiveTypeProperties &properties);
1722+
Type Parent, ArrayRef<Type> GenericArgs);
17251723

17261724
// Implement isa/cast/dyncast/etc.
17271725
static bool classof(const TypeBase *T) {

lib/AST/ASTContext.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3190,15 +3190,12 @@ get(GenericTypeDecl *TheDecl, Type Parent, const ASTContext &C) {
31903190

31913191
void BoundGenericType::Profile(llvm::FoldingSetNodeID &ID,
31923192
NominalTypeDecl *TheDecl, Type Parent,
3193-
ArrayRef<Type> GenericArgs,
3194-
RecursiveTypeProperties &properties) {
3193+
ArrayRef<Type> GenericArgs) {
31953194
ID.AddPointer(TheDecl);
31963195
ID.AddPointer(Parent.getPointer());
3197-
if (Parent) properties |= Parent->getRecursiveProperties();
31983196
ID.AddInteger(GenericArgs.size());
31993197
for (Type Arg : GenericArgs) {
32003198
ID.AddPointer(Arg.getPointer());
3201-
properties |= Arg->getRecursiveProperties();
32023199
}
32033200
}
32043201

@@ -3224,8 +3221,12 @@ BoundGenericType *BoundGenericType::get(NominalTypeDecl *TheDecl,
32243221

32253222
ASTContext &C = TheDecl->getDeclContext()->getASTContext();
32263223
llvm::FoldingSetNodeID ID;
3224+
BoundGenericType::Profile(ID, TheDecl, Parent, GenericArgs);
32273225
RecursiveTypeProperties properties;
3228-
BoundGenericType::Profile(ID, TheDecl, Parent, GenericArgs, properties);
3226+
if (Parent) properties |= Parent->getRecursiveProperties();
3227+
for (Type Arg : GenericArgs) {
3228+
properties |= Arg->getRecursiveProperties();
3229+
}
32293230

32303231
auto arena = getArena(properties);
32313232

0 commit comments

Comments
 (0)