Skip to content

Commit

Permalink
Router: remove { nlPenalty computation
Browse files Browse the repository at this point in the history
Simplify the code a little bit, this penalty was completely superseded
by the lambda penalty execution path.
  • Loading branch information
kitbellew committed Nov 27, 2024
1 parent 8f5626e commit f67830d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -434,23 +434,12 @@ class Router(formatOps: FormatOps) {
}
case _ => NoPolicy
}
val nlPenalty = leftOwner match {
case _ if !style.newlines.fold => 0
case t: Term.ArgClause if (t.values match {
case x :: Nil if !x.is[Term.FunctionTerm] => true
case _ => false
}) => 1
case t @ Tree.Block(x :: Nil)
if !x.is[Term.FunctionTerm] && t.parent.is[Term.ArgClause] => 1
case _ => 0
}
val (nlCost, nlArrowPenalty) =
if (!nl.isNL) (0, 0)
else if (slbMod eq noSplitMod) (1 + nlPenalty, nlPenalty)
else getLambdaPenaltiesOnLeftBraceOnLeft(ft)
.fold((1, nlPenalty)) { case (sharedPenalty, herePenalty) =>
(sharedPenalty + herePenalty, sharedPenalty)
}
else {
if (slbMod eq noSplitMod) None
else getLambdaPenaltiesOnLeftBraceOnLeft(ft)
}.fold((1, 0)) { case (shared, here) => (shared + here, shared) }
val newlineBeforeClosingCurly = decideNewlinesOnlyBeforeClose(close)
val nlPolicy = lambdaNLPolicy ==> newlineBeforeClosingCurly
val nlSplit = Split(nl, nlCost, policy = nlPolicy)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9440,7 +9440,7 @@ object a {
}
}
}
>>> { stateVisits = 2250, stateVisits2 = 2250 }
>>> { stateVisits = 2229, stateVisits2 = 2229 }
object a {
private object MemoMap {
def make(implicit trace: Trace): UIO[MemoMap] = Ref.Synchronized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions {
val explored = Debug.explored.get()
logger.debug(s"Total explored: $explored")
if (!onlyUnit && !onlyManual)
assertEquals(explored, 1183838, "total explored")
assertEquals(explored, 1183640, "total explored")
val results = debugResults.result()
// TODO(olafur) don't block printing out test results.
// I don't want to deal with scalaz's Tasks :'(
Expand Down

0 comments on commit f67830d

Please sign in to comment.