Zum Inhalt springen

Prefer Empty Collection (ARCH8088)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key kotlin.performance.prefer-empty-collection · Severity info · Category performance

Flags arrayOf() and the mutable builders (mutableListOf, hashMapOf …) created empty as a return or default - emptyList() / emptySet() / emptyMap() are shared, allocation-free instances. listOf() is NOT reported: the stdlib declares it as emptyList().

fun tags(): List<String> = listOf()
fun tags(): List<String> = emptyList()

Return emptyList() / emptySet() / emptyMap().