Skip to content

Commit

Permalink
Split: allow ignoring withOptimalAt, relax check
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Jun 16, 2024
1 parent 2c2c5d9 commit 34f0067
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,22 @@ case class Split(
token: => Token,
killOnFail: Boolean = false,
ignore: Boolean = false,
): Split =
if (ignore) this else withOptimalAt(Some(OptimalToken(token, killOnFail)))
): Split = withOptimalAt(Some(OptimalToken(token, killOnFail)), ignore)

def withOptimalAt(fOptimalAt: => Option[OptimalToken]): Split = {
require(this.optimalAt.isEmpty)
if (isIgnored) this
def withOptimalAt(
fOptimalAt: => Option[OptimalToken],
ignore: Boolean = false,
): Split =
if (ignore || isIgnored) this
else {
val optimalAt = fOptimalAt
if (optimalAt.isEmpty) this
else {
require(this.optimalAt.isEmpty)
require(cost == 0, s"can't set optimal, cost=$cost")
copy(optimalAt = optimalAt)
}
}
}

def withPolicy(newPolicy: => Policy, ignore: Boolean = false): Split =
if (isIgnored || ignore) this
Expand Down

0 comments on commit 34f0067

Please sign in to comment.