Migrate collections to arrays for memory optimisation

during import process
This commit is contained in:
Andrey Uskov
2019-07-04 15:37:39 +03:00
parent f6f072693a
commit 09c2b2800c
4 changed files with 21 additions and 18 deletions
@@ -714,7 +714,7 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
ManualLanguageFeatureSetting(feature, LanguageFeature.State.ENABLED, arg)
}
it.useExperimental = languageSettings.experimentalAnnotationsInUse.toTypedArray()
it.pluginOptions = languageSettings.compilerPluginArguments.toTypedArray()
it.pluginOptions = languageSettings.compilerPluginArguments
it.pluginClasspaths = languageSettings.compilerPluginClasspath.map(File::getPath).toTypedArray()
}
}
@@ -733,12 +733,12 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
sourceSetInfo.actualPlatforms.addSimplePlatforms(listOf(compilation.platform))
sourceSetInfo.isTestModule = compilation.isTestModule
sourceSetInfo.compilerArguments =
createCompilerArguments(compilation.arguments.currentArguments, compilation.platform).also {
createCompilerArguments(compilation.arguments.currentArguments.toList(), compilation.platform).also {
it.multiPlatform = true
}
sourceSetInfo.dependencyClasspath = compilation.dependencyClasspath
sourceSetInfo.dependencyClasspath = compilation.dependencyClasspath.toList()
sourceSetInfo.defaultCompilerArguments =
createCompilerArguments(compilation.arguments.defaultArguments, compilation.platform)
createCompilerArguments(compilation.arguments.defaultArguments.toList(), compilation.platform)
sourceSetInfo.addSourceSets(compilation.sourceSets, compilation.fullName(), gradleModule, resolverCtx)
}
}
@@ -760,7 +760,7 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
private fun createCompilerArguments(args: List<String>, platform: KotlinPlatform): CommonCompilerArguments {
val compilerArguments = IdePlatformKindTooling.getTooling(platform).kind.argumentsClass.newInstance()
parseCommandLineArguments(args, compilerArguments)
parseCommandLineArguments(args.toList(), compilerArguments)
return compilerArguments
}
@@ -56,7 +56,7 @@ interface KotlinLanguageSettings : Serializable {
val isProgressiveMode: Boolean
val enabledLanguageFeatures: Set<String>
val experimentalAnnotationsInUse: Set<String>
val compilerPluginArguments: List<String>
val compilerPluginArguments: Array<String>
val compilerPluginClasspath: Set<File>
}
@@ -67,15 +67,15 @@ interface KotlinCompilationOutput : Serializable {
}
interface KotlinCompilationArguments : Serializable {
val defaultArguments: List<String>
val currentArguments: List<String>
val defaultArguments: Array<String>
val currentArguments: Array<String>
}
interface KotlinCompilation : KotlinModule {
val sourceSets: Collection<KotlinSourceSet>
val output: KotlinCompilationOutput
val arguments: KotlinCompilationArguments
val dependencyClasspath: List<String>
val dependencyClasspath: Array<String>
val disambiguationClassifier: String?
val platform: KotlinPlatform
val kotlinTaskProperties: KotlinTaskProperties
@@ -155,7 +155,7 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
getProgressiveMode(gradleLanguageSettings) as? Boolean ?: false,
getEnabledLanguageFeatures(gradleLanguageSettings) as? Set<String> ?: emptySet(),
getExperimentalAnnotationsInUse?.invoke(gradleLanguageSettings) as? Set<String> ?: emptySet(),
getCompilerPluginArguments?.invoke(gradleLanguageSettings) as? List<String> ?: emptyList(),
(getCompilerPluginArguments?.invoke(gradleLanguageSettings) as? List<String> ?: emptyList()).toTypedArray(),
(getCompilerPluginClasspath?.invoke(gradleLanguageSettings) as? FileCollection)?.files ?: emptySet()
)
}
@@ -276,7 +276,7 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
dependencies,
output,
arguments,
dependencyClasspath,
dependencyClasspath.toTypedArray(),
kotlinTaskProperties
)
}
@@ -387,7 +387,7 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
val getDefaultArguments = compileTaskClass.getMethodOrNull("getDefaultSerializedCompilerArguments")
val currentArguments = safelyGetArguments(compileKotlinTask, getCurrentArguments)
val defaultArguments = safelyGetArguments(compileKotlinTask, getDefaultArguments)
return KotlinCompilationArgumentsImpl(defaultArguments, currentArguments)
return KotlinCompilationArgumentsImpl(defaultArguments.toTypedArray(), currentArguments.toTypedArray())
}
private fun buildDependencyClasspath(compileKotlinTask: Task): List<String> {
@@ -46,7 +46,7 @@ data class KotlinLanguageSettingsImpl(
override val isProgressiveMode: Boolean,
override val enabledLanguageFeatures: Set<String>,
override val experimentalAnnotationsInUse: Set<String>,
override val compilerPluginArguments: List<String>,
override val compilerPluginArguments: Array<String>,
override val compilerPluginClasspath: Set<File>
) : KotlinLanguageSettings {
constructor(settings: KotlinLanguageSettings) : this(
@@ -73,10 +73,13 @@ data class KotlinCompilationOutputImpl(
}
data class KotlinCompilationArgumentsImpl(
override val defaultArguments: List<String>,
override val currentArguments: List<String>
override val defaultArguments: Array<String>,
override val currentArguments: Array<String>
) : KotlinCompilationArguments {
constructor(arguments: KotlinCompilationArguments) : this(ArrayList(arguments.defaultArguments), ArrayList(arguments.currentArguments))
constructor(arguments: KotlinCompilationArguments) : this(
arguments.defaultArguments,
arguments.currentArguments
)
}
data class KotlinCompilationImpl(
@@ -85,7 +88,7 @@ data class KotlinCompilationImpl(
override val dependencies: Set<KotlinDependency>,
override val output: KotlinCompilationOutput,
override val arguments: KotlinCompilationArguments,
override val dependencyClasspath: List<String>,
override val dependencyClasspath: Array<String>,
override val kotlinTaskProperties: KotlinTaskProperties
) : KotlinCompilation {
@@ -100,7 +103,7 @@ data class KotlinCompilationImpl(
kotlinCompilation.dependencies.map { it.deepCopy(cloningCache) }.toSet(),
KotlinCompilationOutputImpl(kotlinCompilation.output),
KotlinCompilationArgumentsImpl(kotlinCompilation.arguments),
ArrayList(kotlinCompilation.dependencyClasspath),
kotlinCompilation.dependencyClasspath,
KotlinTaskPropertiesImpl(kotlinCompilation.kotlinTaskProperties)
) {
disambiguationClassifier = kotlinCompilation.disambiguationClassifier