From eae7e4358355f864d9bba1dc512d22fc3a7554e0 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Wed, 7 Nov 2018 11:16:21 +0300 Subject: [PATCH] Avoid redundant String allocations in JvmDescriptorTypeWriter In most cases, jvmCurrentTypeArrayLevel == 0 and we can just use `type` The change was initially suggested by @gorrus --- .../jetbrains/kotlin/load/kotlin/typeSignatureMapping.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/typeSignatureMapping.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/typeSignatureMapping.kt index 337f5cf3094..cc45938b803 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/typeSignatureMapping.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/typeSignatureMapping.kt @@ -366,7 +366,12 @@ open class JvmDescriptorTypeWriter(private val jvmTypeFactory: JvmTypeF protected fun writeJvmTypeAsIs(type: T) { if (jvmCurrentType == null) { - jvmCurrentType = jvmTypeFactory.createFromString("[".repeat(jvmCurrentTypeArrayLevel) + jvmTypeFactory.toString(type)) + jvmCurrentType = + if (jvmCurrentTypeArrayLevel > 0) { + jvmTypeFactory.createFromString("[".repeat(jvmCurrentTypeArrayLevel) + jvmTypeFactory.toString(type)) + } else { + type + } } }