Read Whole File (ARCH8086)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key kotlin.performance.read-whole-file · Severity info · Category performance
Flags readLines() / readText() / readBytes() on a File followed by iteration - the whole file sits in memory when useLines / buffered streaming would not.
Incorrect
Section titled “Incorrect”file.readLines().forEach { parse(it) }Correct
Section titled “Correct”file.useLines { lines -> lines.forEach { parse(it) } }Stream with useLines / bufferedReader().use for files that can be large.