mirror of
https://github.com/sbt/sbt.git
synced 2026-08-22 14:17:13 +02:00
Avoid intermediate collection creation during load
The allKeys method was making many intermediate collections. For akka, this reduced startup time by about 400ms on average.
This commit is contained in:
@@ -25,6 +25,7 @@ import Scope.GlobalScope
|
|||||||
import sbt.internal.parser.SbtParser
|
import sbt.internal.parser.SbtParser
|
||||||
|
|
||||||
import sbt.io.IO
|
import sbt.io.IO
|
||||||
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is responsible for compiling the .sbt files used to configure sbt builds.
|
* This file is responsible for compiling the .sbt files used to configure sbt builds.
|
||||||
@@ -340,11 +341,15 @@ object Index {
|
|||||||
pairs.toMap[Task[_], ScopedKey[Task[_]]]
|
pairs.toMap[Task[_], ScopedKey[Task[_]]]
|
||||||
}
|
}
|
||||||
|
|
||||||
def allKeys(settings: Seq[Setting[_]]): Set[ScopedKey[_]] =
|
def allKeys(settings: Seq[Setting[_]]): Set[ScopedKey[_]] = {
|
||||||
settings
|
val result = new java.util.HashSet[ScopedKey[_]]
|
||||||
.flatMap(s => if (s.key.key.isLocal) Nil else s.key +: s.dependencies)
|
settings.foreach { s =>
|
||||||
.filter(!_.key.isLocal)
|
if (!s.key.key.isLocal && result.add(s.key)) {
|
||||||
.toSet
|
s.dependencies.foreach(k => if (!k.key.isLocal) result.add(s.key))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.asScala.toSet
|
||||||
|
}
|
||||||
|
|
||||||
def attributeKeys(settings: Settings[Scope]): Set[AttributeKey[_]] =
|
def attributeKeys(settings: Settings[Scope]): Set[AttributeKey[_]] =
|
||||||
settings.data.values.flatMap(_.keys).toSet[AttributeKey[_]]
|
settings.data.values.flatMap(_.keys).toSet[AttributeKey[_]]
|
||||||
|
|||||||
Reference in New Issue
Block a user