Skip to content

Commit 1e6bdf7

Browse files
[AST] Change TypeBase::getOptionalityDepth() implementation to not use a vector
1 parent 5d832bf commit 1e6bdf7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/AST/Type.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,9 +906,13 @@ Type TypeBase::lookThroughAllOptionalTypes(SmallVectorImpl<Type> &optionals){
906906
}
907907

908908
unsigned int TypeBase::getOptionalityDepth() {
909-
SmallVector<Type> types;
910-
lookThroughAllOptionalTypes(types);
911-
return types.size();
909+
Type type(this);
910+
unsigned int depth = 0;
911+
while (auto objType = type->getOptionalObjectType()) {
912+
type = objType;
913+
++depth;
914+
}
915+
return depth;
912916
}
913917

914918
Type TypeBase::stripConcurrency(bool recurse, bool dropGlobalActor) {

0 commit comments

Comments
 (0)