From e763e715154df90e706136ea060b06febcef4739 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Thu, 17 Aug 2023 16:11:05 +0200 Subject: [PATCH] [FIR] optimize ConeTypeProjection[] RAM usage for empty arrays On the snapshot from ^KTIJ-26260 empty ConeTypeProjection arrays take about 10mb --- .../fir/cones/src/org/jetbrains/kotlin/fir/types/impl/Impl.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/Impl.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/Impl.kt index c284a417324..f02a92fe243 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/Impl.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/Impl.kt @@ -14,10 +14,12 @@ import org.jetbrains.kotlin.util.WeakPair class ConeClassLikeTypeImpl( override val lookupTag: ConeClassLikeLookupTag, - override val typeArguments: Array, + typeArguments: Array, isNullable: Boolean, override val attributes: ConeAttributes = ConeAttributes.Empty ) : ConeClassLikeType() { + override val typeArguments = if (typeArguments.isEmpty()) EMPTY_ARRAY else typeArguments + override val nullability: ConeNullability = ConeNullability.create(isNullable) // Cached expanded type and the relevant session