Skip to content

Commit

Permalink
Improve performance of LookupAnalysis via pre-built index
Browse files Browse the repository at this point in the history
  • Loading branch information
Friendseeker committed Nov 5, 2023
1 parent 72101b7 commit 95fdd99
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion zinc/src/main/scala/sbt/internal/inc/LookupImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ class LookupImpl(compileConfiguration: CompileConfiguration, previousSetup: Opti
}
}

private lazy val binaryClassNameToAnalysis: Map[String, Analysis] = {
analyses.flatMap { analysis =>
analysis.relations.productClassName._2s.map { binaryClassName =>
binaryClassName -> analysis
}
}.toMap
}

lazy val previousClasspathHash: Vector[FileHash] = {
previousSetup match {
case Some(x) => x.options.classpathHash.toVector
Expand All @@ -45,7 +53,7 @@ class LookupImpl(compileConfiguration: CompileConfiguration, previousSetup: Opti
private val entry = MixedAnalyzingCompiler.classPathLookup(compileConfiguration)

override def lookupAnalysis(binaryClassName: String): Option[CompileAnalysis] =
analyses.find(_.relations.productClassName._2s.contains(binaryClassName))
binaryClassNameToAnalysis.get(binaryClassName)

override def lookupOnClasspath(binaryClassName: String): Option[VirtualFileRef] =
entry(binaryClassName)
Expand Down

0 comments on commit 95fdd99

Please sign in to comment.