Return sequence instead of list from parse method
This commit is contained in:
parent
7c16182d61
commit
73e627b6be
@ -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() }
|
||||||
|
@ -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)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user