Rule Definition
In most cases using a spread operator causes a full copy of the array to be created before calling a method. This has a very high performance penalty.
The decrease in performance in Kotlin as compared to Java is double in such case.
Remediation
1. Pass values rather than arrays
Violation Code Sample
val strs = arrayOf("value one", "value two")
val foo = bar(*strs) //Violation
fun bar(vararg strs: String) {
strs.forEach { println(it) }
}
Fixed Code Sample
val foo2 = bar("value one", "value two")
fun bar(vararg strs: String) {
strs.forEach { println(it) }
}
Reference
https://sites.google.com/a/athaydes.com/renato-athaydes/posts/kotlinshiddencosts-benchmarks
Related Technologies
Technical Criterion
Efficiency - Memory, Network and Disk Space Management
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.