Kotlin

Kotlin

Made by DeepSource

Specialized primitive array classes should be preferred over Array<Primitive> KT-P1003

Performance
Minor

In Kotlin, using Array<Primitive> can lead to implicit boxing, which can reduce performance. Kotlin provides specialized array classes for each primitive type (e.g., IntArray, DoubleArray, BooleanArray, etc.), which offer better performance and avoid unnecessary boxing and unboxing operations.

Bad Practice

fun function(array: Array<Int>) {
    // ..
}

Recommended

Prefer specialized array classes over Array<Primitive>.

fun function(array: IntArray) {
    // ..
}