Return sequence instead of list from parse method

This commit is contained in:
Marvin Elsen 2024-09-24 10:34:00 +02:00
parent 7c16182d61
commit 73e627b6be
Signed by: marvinelsen
GPG Key ID: 820672408CC318C2
2 changed files with 2 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import com.marvinelsen.cedict.internal.CedictParserImpl
import java.io.InputStream import java.io.InputStream
interface CedictParser { interface CedictParser {
fun parseCedict(inputStream: InputStream): List<CedictEntry> fun parseCedict(inputStream: InputStream): Sequence<CedictEntry>
companion object { companion object {
val instance: CedictParser by lazy { CedictParserImpl() } val instance: CedictParser by lazy { CedictParserImpl() }

View File

@ -22,7 +22,7 @@ internal class CedictParserImpl : CedictParser {
override fun parseCedict(inputStream: InputStream) = override fun parseCedict(inputStream: InputStream) =
inputStream inputStream
.bufferedReader() .bufferedReader()
.readLines() .lineSequence()
.filterNot(::isComment) .filterNot(::isComment)
.map(::toCedictEntry) .map(::toCedictEntry)