CLI: Change kotlin reflection to java reflection
The command line argument parser is using between 0.25s and 0.5s (depending on platform) on finding annotated properties. This fix replaces the slow kotlin reflection with java reflection, which is an order of magnitude faster. #KT-58183 Fixed
This commit is contained in:
committed by
Space Team
parent
b28b0e70b6
commit
111bb461a9
@@ -16,17 +16,18 @@ import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KProperty1
|
||||
import kotlin.reflect.full.declaredMemberProperties
|
||||
import kotlin.reflect.full.withNullability
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
// Additional properties that should be included in interface
|
||||
// Additional properties that should be included
|
||||
@Suppress("unused")
|
||||
interface AdditionalGradleProperties {
|
||||
private class AdditionalGradleProperties {
|
||||
@GradleOption(
|
||||
value = DefaultValue.EMPTY_STRING_LIST_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT,
|
||||
shouldGenerateDeprecatedKotlinOptions = true,
|
||||
)
|
||||
@Argument(value = "", description = "A list of additional compiler arguments")
|
||||
var freeCompilerArgs: List<String>
|
||||
var freeCompilerArgs = listOf<String>()
|
||||
}
|
||||
|
||||
private data class GeneratedOptions(
|
||||
@@ -869,7 +870,7 @@ private fun Printer.generateOptionDeprecation(property: KProperty1<*, *>) {
|
||||
}
|
||||
|
||||
private fun Printer.generateDoc(property: KProperty1<*, *>) {
|
||||
val description = property.findAnnotation<Argument>()!!.description
|
||||
val description = property.javaField!!.getAnnotation(Argument::class.java).description
|
||||
val possibleValues = property.gradleValues.possibleValues
|
||||
val defaultValue = property.gradleValues.defaultValue
|
||||
|
||||
@@ -896,7 +897,7 @@ private fun generateMarkdown(properties: List<KProperty1<*, *>>) {
|
||||
if (name == "includeRuntime") continue // This option has no effect in Gradle builds
|
||||
val renderName = listOfNotNull("`$name`", property.findAnnotation<GradleDeprecatedOption>()?.let { "__(Deprecated)__" })
|
||||
.joinToString(" ")
|
||||
val description = property.findAnnotation<Argument>()!!.description
|
||||
val description = property.javaField!!.getAnnotation(Argument::class.java).description
|
||||
val possibleValues = property.gradleValues.possibleValues
|
||||
val defaultValue = when (property.gradleDefaultValue) {
|
||||
"null" -> ""
|
||||
|
||||
Reference in New Issue
Block a user