Skip to content

Commit

Permalink
BestFirstSearch: try memorize partial functions
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Oct 29, 2024
1 parent 9aa37cc commit a0a013d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ object BestFirstSearch {
var expire: FormatToken = null
@inline
def addRange(t: Token): Unit = expire = tokens.matching(t)
@inline
def addBlock(t: Token): Unit = result.getOrElseUpdate(t, false)
tokens.foreach {
case ft if expire ne null =>
if (ft eq expire) expire = null else result.update(ft.left, true)
Expand All @@ -332,6 +334,8 @@ object BestFirstSearch {
// Type compounds can be inside defn.defs
case lo: meta.Stat.Block if lo.parent.is[Type.Refine] => addRange(t)
case _: Type.Refine => addRange(t)
case _: Term.PartialFunction if styleMap.at(t).newlines.fold =>
addBlock(t)
case _ =>
}
case _ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9460,7 +9460,7 @@ object a {
}
}
}
>>> { stateVisits = 2428, stateVisits2 = 2428 }
>>> { stateVisits = 8595, stateVisits2 = 8595 }
object a {
private object MemoMap {
def make(implicit trace: Trace): UIO[MemoMap] = Ref.Synchronized
Expand Down Expand Up @@ -10059,7 +10059,6 @@ object a {
preset = default
maxColumn = 80
newlines.source = fold
runner.maxStateVisits = 80000
#newlines.avoidForSimpleOverflow = all
===
system.dynamicAccess.createInstanceFor[Serializer](fqn, Nil).recoverWith {
Expand Down Expand Up @@ -10091,7 +10090,7 @@ system.dynamicAccess.createInstanceFor[Serializer](fqn, Nil).recoverWith {
}
}
}
>>> { stateVisits = 72590, stateVisits2 = 72590 }
>>> { stateVisits = 5817, stateVisits2 = 5817 }
system.dynamicAccess.createInstanceFor[Serializer](fqn, Nil).recoverWith {
case _: NoSuchMethodException => system.dynamicAccess
.createInstanceFor[Serializer](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,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, 1620763, "total explored")
assertEquals(explored, 1499555, "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 a0a013d

Please sign in to comment.