[FIR] optimize direct allocation of empty ConeTypeProjection arrays

On the snapshot from KTIJ-26260 empty ConeTypeProjection arrays take about 10mb
This commit is contained in:
Ilya Kirillov
2023-08-17 16:10:28 +02:00
committed by Space Team
parent 04d330edae
commit bdfc68468f
19 changed files with 35 additions and 24 deletions
@@ -187,7 +187,7 @@ abstract class AbstractAnnotationDeserializer(
val classId = nameResolver.getClassId(proto.id)
return buildAnnotation {
annotationTypeRef = buildResolvedTypeRef {
type = classId.toLookupTag().constructClassType(emptyArray(), isNullable = false)
type = classId.toLookupTag().constructClassType(ConeTypeProjection.EMPTY_ARRAY, isNullable = false)
}
session.lazyDeclarationResolver.disableLazyResolveContractChecksInside {
this.argumentMapping = createArgumentMapping(proto, classId, nameResolver)
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirEnumEntrySymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
import org.jetbrains.kotlin.fir.types.ConeTypeProjection
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
import org.jetbrains.kotlin.fir.types.coneTypeSafe
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
@@ -168,7 +169,7 @@ fun deserializeClassToSymbol(
classProto.enumEntryList.mapNotNull { enumEntryProto ->
val enumEntryName = nameResolver.getName(enumEntryProto.name)
val enumType = ConeClassLikeTypeImpl(symbol.toLookupTag(), emptyArray(), false)
val enumType = ConeClassLikeTypeImpl(symbol.toLookupTag(), ConeTypeProjection.EMPTY_ARRAY, false)
val property = buildEnumEntry {
this.moduleData = moduleData
this.origin = FirDeclarationOrigin.Library
@@ -265,7 +266,7 @@ fun FirRegularClassBuilder.addCloneForArrayIfNeeded(classId: ClassId, dispatchRe
superTypeRefs += buildResolvedTypeRef {
type = ConeClassLikeTypeImpl(
StandardClassIds.Cloneable.toLookupTag(),
typeArguments = emptyArray(),
typeArguments = ConeTypeProjection.EMPTY_ARRAY,
isNullable = false
)
}
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference
import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference
import org.jetbrains.kotlin.fir.resolve.providers.getClassDeclaredPropertySymbols
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
import org.jetbrains.kotlin.fir.types.ConeTypeProjection
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
import org.jetbrains.kotlin.fir.types.toLookupTag
@@ -45,7 +46,7 @@ fun FirEnumEntryDeserializedAccessExpression.toQualifiedPropertyAccessExpression
typeRef = buildResolvedTypeRef {
type = ConeClassLikeTypeImpl(
enumClassId.toLookupTag(), emptyArray(), isNullable = false
enumClassId.toLookupTag(), ConeTypeProjection.EMPTY_ARRAY, isNullable = false
)
}
}