Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PolicySummary: return only splits in execute #4037

Merged
merged 1 commit into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private class BestFirstSearch private (
private def getActiveSplits(state: State, maxCost: Int): Seq[Split] = {
val ft = tokens(state.depth)
val useProvided = ft.meta.formatOff || !ft.inside(range)
val active = state.policy.execute(Decision(ft, routes(state.depth))).splits
val active = state.policy.execute(Decision(ft, routes(state.depth)))
.filter(x => x.isActive && x.cost <= maxCost)
val splits =
if (useProvided && active.nonEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class PolicySummary(val policies: Seq[Policy]) extends AnyVal {
.sortBy(_.rank),
)

def execute(decision: Decision, debug: Boolean = false): Decision = policies
def execute(decision: Decision, debug: Boolean = false): Seq[Split] = policies
.foldLeft(decision) { case (result, policy) =>
def withSplits(splits: Seq[Split]): Decision = {
if (debug) logger.debug(s"$policy defined at $result")
result.withSplits(splits)
}
policy.f.andThen(withSplits _).applyOrElse(result, identity[Decision])
}
}.splits

}

Expand Down
Loading