Use ArrayList for history, avoid linear time for last() method.

This commit is contained in:
Fedor Isakov 2019-07-29 13:41:18 +02:00
parent 66c9222a95
commit ba604c2f80
1 changed files with 2 additions and 2 deletions

View File

@ -47,13 +47,13 @@ internal open class MatchJournalImpl(
if (view == null) {
nextChunkId = 0
val initChunk = MatchChunk(nextChunkId++, InitRuleMatch)
hist = IteratorMutableList(LinkedList<Chunk>().apply { add(initChunk) })
hist = IteratorMutableList(ArrayList<Chunk>().apply { add(initChunk) })
} else {
// assert that initial chunk is present
with (view.chunks.first()) {
assert(this is MatchChunk && match is InitRuleMatch)
}
hist = IteratorMutableList(LinkedList(view.chunks as List<Chunk>))
hist = IteratorMutableList(ArrayList(view.chunks as List<Chunk>))
nextChunkId = view.nextChunkId
}
}