Avoid redundant String allocations in JvmDescriptorTypeWriter

In most cases, jvmCurrentTypeArrayLevel == 0 and we can just use `type`
The change was initially suggested by @gorrus
This commit is contained in:
Denis Zharkov
2018-11-07 11:16:21 +03:00
parent 4ae837e669
commit eae7e43583
@@ -366,7 +366,12 @@ open class JvmDescriptorTypeWriter<T : Any>(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
}
}
}