From 1e6bdf73ad63a93e4682c912bcb73114bbfab185 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Wed, 12 Oct 2022 17:11:18 -0300 Subject: [PATCH] [AST] Change TypeBase::getOptionalityDepth() implementation to not use a vector --- lib/AST/Type.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 5640716a766ff..09676d993eebe 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -906,9 +906,13 @@ Type TypeBase::lookThroughAllOptionalTypes(SmallVectorImpl &optionals){ } unsigned int TypeBase::getOptionalityDepth() { - SmallVector types; - lookThroughAllOptionalTypes(types); - return types.size(); + Type type(this); + unsigned int depth = 0; + while (auto objType = type->getOptionalObjectType()) { + type = objType; + ++depth; + } + return depth; } Type TypeBase::stripConcurrency(bool recurse, bool dropGlobalActor) {