Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid intermediate mapping in ZincWorkerImpl #2661

Merged
merged 1 commit into from
Jul 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 5 additions & 56 deletions scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -297,26 +297,6 @@ class ZincWorkerImpl(
reporter: Option[CompileProblemReporter],
reportCachedProblems: Boolean
)(implicit ctx: ZincWorkerApi.Ctx): Result[CompilationResult] = {

for (
res <- compileJava0(
upstreamCompileOutput = upstreamCompileOutput.map(c => (c.analysisFile, c.classes.path)),
sources = sources,
compileClasspath = compileClasspath,
javacOptions = javacOptions,
reporter = reporter,
reportCachedProblems = reportCachedProblems
)
) yield CompilationResult(res._1, PathRef(res._2))
}
def compileJava0(
upstreamCompileOutput: Seq[(os.Path, os.Path)],
sources: Agg[os.Path],
compileClasspath: Agg[os.Path],
javacOptions: Seq[String],
reporter: Option[CompileProblemReporter],
reportCachedProblems: Boolean
)(implicit ctx: ZincWorkerApi.Ctx): Result[(os.Path, os.Path)] = {
compileInternal(
upstreamCompileOutput = upstreamCompileOutput,
sources = sources,
Expand All @@ -342,37 +322,6 @@ class ZincWorkerImpl(
reporter: Option[CompileProblemReporter],
reportCachedProblems: Boolean
)(implicit ctx: ZincWorkerApi.Ctx): Result[CompilationResult] = {

for (
res <- compileMixed0(
upstreamCompileOutput.map(c => (c.analysisFile, c.classes.path)),
sources,
compileClasspath,
javacOptions,
scalaVersion,
scalaOrganization,
scalacOptions,
compilerClasspath,
scalacPluginClasspath,
reporter,
reportCachedProblems
)
) yield CompilationResult(res._1, PathRef(res._2))
}

def compileMixed0(
upstreamCompileOutput: Seq[(os.Path, os.Path)],
sources: Agg[os.Path],
compileClasspath: Agg[os.Path],
javacOptions: Seq[String],
scalaVersion: String,
scalaOrganization: String,
scalacOptions: Seq[String],
compilerClasspath: Agg[PathRef],
scalacPluginClasspath: Agg[PathRef],
reporter: Option[CompileProblemReporter],
reportOldProblems: Boolean
)(implicit ctx: ZincWorkerApi.Ctx): Result[(os.Path, os.Path)] = {
withCompilers(
scalaVersion = scalaVersion,
scalaOrganization = scalaOrganization,
Expand All @@ -388,7 +337,7 @@ class ZincWorkerImpl(
scalacOptions = scalacOptions,
compilers = compilers,
reporter = reporter,
reportOldProblems: Boolean
reportCachedProblems: Boolean
)
}
}
Expand Down Expand Up @@ -463,15 +412,15 @@ class ZincWorkerImpl(
}

private def compileInternal(
upstreamCompileOutput: Seq[(os.Path, os.Path)],
upstreamCompileOutput: Seq[CompilationResult],
sources: Agg[os.Path],
compileClasspath: Agg[os.Path],
javacOptions: Seq[String],
scalacOptions: Seq[String],
compilers: Compilers,
reporter: Option[CompileProblemReporter],
reportCachedProblems: Boolean
)(implicit ctx: ZincWorkerApi.Ctx): Result[(os.Path, os.Path)] = {
)(implicit ctx: ZincWorkerApi.Ctx): Result[CompilationResult] = {
os.makeDir.all(ctx.dest)

reporter.foreach(_.start())
Expand Down Expand Up @@ -512,7 +461,7 @@ class ZincWorkerImpl(
}
}
}
val analysisMap0 = upstreamCompileOutput.map(_.swap).toMap
val analysisMap0 = upstreamCompileOutput.map(c => c.classes.path -> c.analysisFile).toMap

def analysisMap(f: VirtualFile): Optional[CompileAnalysis] = {
val analysisFile = f match {
Expand Down Expand Up @@ -615,7 +564,7 @@ class ZincWorkerImpl(
newResult.setup()
)
)
Result.Success((zincFile, classesDir))
Result.Success(CompilationResult(zincFile, PathRef(classesDir)))
} catch {
case e: CompileFailed =>
Result.Failure(e.toString)
Expand Down