Skip to content

Commit b74afb4

Browse files
committed
Avoid quadratic performance wrt classpath length
1 parent 29c9cbc commit b74afb4

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/compiler/scala/tools/nsc/PipelineMain.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class PipelineMainClass(label: String, parallelism: Int, strategy: BuildStrategy
184184
case OutlineTypePipeline =>
185185
projects.foreach { p =>
186186
val isLeaf = !dependedOn.contains(p)
187-
val depsReady = Future.sequence(dependsOn.getOrElse(p, Nil).map { task => p.dependencyReadyFuture(task.t) })
187+
val depsReady = Future.sequence(dependsOn.getOrElse(p, Nil).map { task => p.dependencyReadyFuture(task) })
188188
val f = if (isLeaf) {
189189
for {
190190
_ <- depsReady
@@ -234,7 +234,7 @@ class PipelineMainClass(label: String, parallelism: Int, strategy: BuildStrategy
234234
println(f" Wall Clock: ${timer.durationMs}%.0f ms")
235235
case Pipeline =>
236236
projects.foreach { p =>
237-
val depsReady = Future.sequence(dependsOn.getOrElse(p, Nil).map(task => p.dependencyReadyFuture(task.t)))
237+
val depsReady = Future.sequence(dependsOn.getOrElse(p, Nil).iterator.map(task => p.dependencyReadyFuture(task)))
238238
val f = for {
239239
_ <- depsReady
240240
_ <- {
@@ -348,23 +348,23 @@ class PipelineMainClass(label: String, parallelism: Int, strategy: BuildStrategy
348348
private def expand(s: command.settings.PathSetting): List[Path] = {
349349
ClassPath.expandPath(s.value, expandStar = true).map(s => Paths.get(s).toAbsolutePath.normalize())
350350
}
351-
def classPath: Seq[Path] = expand(command.settings.classpath)
352-
def macroClassPath: Seq[Path] = expand(command.settings.YmacroClasspath)
353-
def macroClassPathSet: Set[Path] = macroClassPath.toSet
354-
def pluginClassPath: Set[Path] = {
351+
lazy val classPath: Seq[Path] = expand(command.settings.classpath)
352+
lazy val macroClassPath: Seq[Path] = expand(command.settings.YmacroClasspath)
353+
lazy val macroClassPathSet: Set[Path] = macroClassPath.toSet
354+
lazy val pluginClassPath: Set[Path] = {
355355
def asPath(p: String) = ClassPath split p
356356

357357
val paths = command.settings.plugin.value filter (_ != "") flatMap (s => asPath(s) map (s => Paths.get(s)))
358358
paths.toSet
359359
}
360-
def dependencyReadyFuture(dependency: Task) = if (macroClassPathSet.contains(dependency.outputDir)) {
361-
log(s"dependency is on macro classpath, will wait for .class files: ${dependency.label}")
362-
dependency.javaDone.future
363-
} else if (pluginClassPath.contains(dependency.outputDir)) {
364-
log(s"dependency is on plugin classpath, will wait for .class files: ${dependency.label}")
365-
dependency.javaDone.future
360+
def dependencyReadyFuture(dependency: Dependency) = if (dependency.isMacro) {
361+
log(s"dependency is on macro classpath, will wait for .class files: ${dependency.t.label}")
362+
dependency.t.javaDone.future
363+
} else if (dependency.isPlugin) {
364+
log(s"dependency is on plugin classpath, will wait for .class files: ${dependency.t.label}")
365+
dependency.t.javaDone.future
366366
} else
367-
dependency.outlineDone.future
367+
dependency.t.outlineDone.future
368368

369369

370370
val cacheMacro = java.lang.Boolean.getBoolean("scala.pipeline.cache.macro.classloader")

0 commit comments

Comments
 (0)