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
+2
-2
@@ -17,8 +17,8 @@ import org.jetbrains.kotlin.diagnostics.impl.BaseDiagnosticsCollector
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
|
||||
import org.jetbrains.kotlin.psi
|
||||
import org.jetbrains.kotlin.scripting.definitions.MessageReporter
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
import kotlin.reflect.jvm.javaField
|
||||
import kotlin.script.experimental.api.ResultWithDiagnostics
|
||||
import kotlin.script.experimental.api.ScriptDiagnostic
|
||||
import kotlin.script.experimental.api.SourceCode
|
||||
@@ -194,7 +194,7 @@ private fun reportInvalidArguments(
|
||||
): Boolean {
|
||||
val invalidArgKeys = toIgnore.mapNotNull { argProperty ->
|
||||
if (argProperty.get(arguments) != argProperty.get(reportingState.currentArguments)) {
|
||||
argProperty.annotations.firstIsInstanceOrNull<Argument>()?.value
|
||||
argProperty.javaField?.getAnnotation(Argument::class.java)?.value
|
||||
?: throw IllegalStateException("unknown compiler argument property: $argProperty: no Argument annotation found")
|
||||
} else null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user