Fix incorrect reset of occurrences that led to invalid occurrences state

Resulted in some in fact dead occurrences being reactivated
This commit is contained in:
Grigorii Kirgizov 2020-04-21 21:20:30 +03:00
parent 09f4a54943
commit 14e4385382
1 changed files with 5 additions and 4 deletions

View File

@ -299,9 +299,10 @@ internal open class MatchJournalImpl(
if (posPtr.hasNext()) posPtr.next()
}
private fun resetOccurrences(occSpecs: Iterable<Chunk.Entry>) =
// todo: need iterating over reversed list?
occSpecs.forEach {
private fun resetOccurrences(occSpecs: List<Chunk.Entry>) =
// assume occSpecs are ordered in order of processing
// so, iterate over reversed list
occSpecs.asReversed().forEach {
if (it.discarded) {
it.occ.alive = true
it.occ.stored = true
@ -311,7 +312,7 @@ internal open class MatchJournalImpl(
}
}
private fun replayOccurrences(occSpecs: Iterable<Chunk.Entry>) =
private fun replayOccurrences(occSpecs: List<Chunk.Entry>) =
occSpecs.forEach {
if (it.discarded) {
// it.occ.terminate(observable)