Skip to content

Commit

Permalink
BestFirstSearch: don't recurse if isOpt
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Oct 28, 2024
1 parent bb47eb3 commit f7c3d6a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ private class BestFirstSearch private (range: Set[Range])(implicit
): Option[Option[State]] = {
val key = (start.indentation & 0xffL) | (start.column & 0xffffffL) << 8 |
(start.depth & 0xffffffffL) << 32
def orElse = {
val nextState = shortestPath(start, stop, depth, isOpt).toOption
if (nextState.isDefined || !isOpt && !start.hasSlb()) memo
.update(key, nextState)
Some(nextState)
}
def orElse =
if (isOpt) Some(None) // we wouldn't recurse unless the span was large
else {
val nextState = shortestPath(start, stop, depth, isOpt).toOption
if (nextState.isDefined || !start.hasSlb()) memo.update(key, nextState)
Some(nextState)
}
memo.get(key).orElse(orElse)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ private def withNewLocalDefs = {
}))
}))
}
>>> { stateVisits = 3779 }
>>> { stateVisits = 3750 }
val createIsArrayOfStat = {
envFieldDef(
"isArrayOf",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class ResolutionCopier(x: Int) {
toNode.rightBracket));
}
}
>>> { stateVisits = 57714 }
>>> { stateVisits = 57624 }
class ResolutionCopier(x: Int) {

def visitClassDeclaration(node: ClassDeclaration): Boolean = {
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, 1487762, "total explored")
assertEquals(explored, 1484918, "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 f7c3d6a

Please sign in to comment.