Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Various Task Manage Speedups #373

Merged
merged 10 commits into from
Mar 25, 2020
6 changes: 4 additions & 2 deletions core/src/main/scala/dagr/core/tasksystem/Pipeline.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ abstract class Pipeline(val outputDirectory: Option[Path] = None,

/** Recursively navigates dependencies, starting from the supplied task, and add all children to this.tasks. */
private def addChildren(task : Task) : Unit = {
tasks ++= task.tasksDependingOnThisTask
task.tasksDependingOnThisTask.foreach(addChildren)
task.tasksDependingOnThisTask.filterNot(tasks.contains).foreach { child =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than doing a filterNot here, I think you could write this as:

task.tasksDependingOnThisTask.foreach { child =>
  if (tasks.add(child)) addChildren(child)
}

The bonus being that for tasks that have not been previously added you're not checking the set twice.

tasks += child
addChildren(child)
}
}

/** True if we this pipeline is tracking this direct ancestor task, false otherwise. */
Expand Down