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 4be32d0 commit 188cc88
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 17 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 @@ -13,7 +13,7 @@ abstract class CommunityIntellijScalaSuite(name: String)
class CommunityIntellijScala_2024_2_Suite
extends CommunityIntellijScalaSuite("intellij-scala-2024.2") {

override protected def totalStatesVisited: Option[Int] = Some(47833716)
override protected def totalStatesVisited: Option[Int] = Some(47828843)

override protected def builds = Seq(getBuild(
"2024.2.28",
Expand Down Expand Up @@ -51,7 +51,7 @@ class CommunityIntellijScala_2024_2_Suite
class CommunityIntellijScala_2024_3_Suite
extends CommunityIntellijScalaSuite("intellij-scala-2024.3") {

override protected def totalStatesVisited: Option[Int] = Some(48012302)
override protected def totalStatesVisited: Option[Int] = Some(48007538)

override protected def builds = Seq(getBuild(
"2024.3.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ abstract class CommunityScala2Suite(name: String)

class CommunityScala2_12Suite extends CommunityScala2Suite("scala-2.12") {

override protected def totalStatesVisited: Option[Int] = Some(35259829)
override protected def totalStatesVisited: Option[Int] = Some(35257028)

override protected def builds =
Seq(getBuild("v2.12.20", dialects.Scala212, 1277))
Expand All @@ -18,7 +18,7 @@ class CommunityScala2_12Suite extends CommunityScala2Suite("scala-2.12") {

class CommunityScala2_13Suite extends CommunityScala2Suite("scala-2.13") {

override protected def totalStatesVisited: Option[Int] = Some(43931304)
override protected def totalStatesVisited: Option[Int] = Some(43926266)

override protected def builds =
Seq(getBuild("v2.13.14", dialects.Scala213, 1287))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ abstract class CommunityScala3Suite(name: String)

class CommunityScala3_2Suite extends CommunityScala3Suite("scala-3.2") {

override protected def totalStatesVisited: Option[Int] = Some(32918646)
override protected def totalStatesVisited: Option[Int] = Some(32909474)

override protected def builds = Seq(getBuild("3.2.2", dialects.Scala32, 791))

}

class CommunityScala3_3Suite extends CommunityScala3Suite("scala-3.3") {

override protected def totalStatesVisited: Option[Int] = Some(35518295)
override protected def totalStatesVisited: Option[Int] = Some(35508610)

override protected def builds = Seq(getBuild("3.3.3", dialects.Scala33, 861))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ abstract class CommunitySparkSuite(name: String)

class CommunitySpark3_4Suite extends CommunitySparkSuite("spark-3.4") {

override protected def totalStatesVisited: Option[Int] = Some(71540745)
override protected def totalStatesVisited: Option[Int] = Some(71532918)

override protected def builds =
Seq(getBuild("v3.4.1", dialects.Scala213, 2585))
Expand All @@ -18,7 +18,7 @@ class CommunitySpark3_4Suite extends CommunitySparkSuite("spark-3.4") {

class CommunitySpark3_5Suite extends CommunitySparkSuite("spark-3.5") {

override protected def totalStatesVisited: Option[Int] = Some(75678453)
override protected def totalStatesVisited: Option[Int] = Some(75670780)

override protected def builds =
Seq(getBuild("v3.5.3", dialects.Scala213, 2756))
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 188cc88

Please sign in to comment.