From b3e0770939c3b6782a9a0ab11409475ed816b0d1 Mon Sep 17 00:00:00 2001 From: Grigorii Kirgizov Date: Tue, 11 Jun 2019 18:57:41 +0300 Subject: [PATCH] minor: slightly rearrange code in ProcessingStateImpl --- .../reactor/core/internal/ProcessingStateImpl.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt index 7f8c47d7..c368bdc4 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt @@ -59,7 +59,7 @@ internal class ProcessingStateImpl(private var dispatchingFront: Dispatcher.Disp private val postponedMatches: MutableMap, List> = HashMap() private val execQueue: Queue = - PriorityQueue(1 + this.count() / 2) { + PriorityQueue(1 + this.count() / 2) { // just an estimate lhs, rhs -> journalIndex.compare(lhs.pos, rhs.pos) } @@ -133,8 +133,6 @@ internal class ProcessingStateImpl(private var dispatchingFront: Dispatcher.Disp } } - private fun Justs.intersects(other: Iterable): Boolean = other.any { this.contains(it) } - private data class MatchCandidate(val rule: Rule, val occ: Occurrence, val occParentId: Int) private fun canMatch(rule: Rule, occ: Occurrence): Boolean = @@ -284,9 +282,6 @@ internal class ProcessingStateImpl(private var dispatchingFront: Dispatcher.Disp } } - // TODO: provide ispec to ProcessingStateImpl and use it - private fun Occurrence.isPrincipal() = this.constraint().isPrincipal() - // Determines, filters out and enqueues (to execution queue) future matches. Returns only current matches. private fun handleFutureMatches(matches: List): List { val currentMatches = mutableListOf() @@ -353,6 +348,12 @@ internal class ProcessingStateImpl(private var dispatchingFront: Dispatcher.Disp } + // TODO: provide ispec to ProcessingStateImpl and use it + private fun Occurrence.isPrincipal() = this.constraint().isPrincipal() + + private fun Justs.intersects(other: Iterable): Boolean = other.any { this.contains(it) } + private fun RuleMatch.allHeads() = matchHeadKept() + matchHeadReplaced() + private fun RuleMatch.allStored() = allHeads().all { co -> (co as Occurrence).stored } }