mirror of https://github.com/sbt/sbt.git
Add comments
This commit is contained in:
parent
9382fc99b7
commit
2f726cddf0
|
|
@ -337,6 +337,8 @@ object Project:
|
||||||
[a] => (k: ScopedKey[a]) => ScopedKey(f(k.scope), k.key)
|
[a] => (k: ScopedKey[a]) => ScopedKey(f(k.scope), k.key)
|
||||||
|
|
||||||
def transform(g: Scope => Scope, ss: Seq[Def.Setting[?]]): Seq[Def.Setting[?]] =
|
def transform(g: Scope => Scope, ss: Seq[Def.Setting[?]]): Seq[Def.Setting[?]] =
|
||||||
|
// We use caching to avoid creating new Scope instances too many times
|
||||||
|
// Creating a new Scope is CPU expensive because of the uniqueness cache
|
||||||
val f = mapScope(Util.withCaching(g))
|
val f = mapScope(Util.withCaching(g))
|
||||||
ss.map(_.mapKey(f).mapReferenced(f))
|
ss.map(_.mapKey(f).mapReferenced(f))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ final case class Scope private (
|
||||||
task: ScopeAxis[AttributeKey[?]],
|
task: ScopeAxis[AttributeKey[?]],
|
||||||
extra: ScopeAxis[AttributeMap]
|
extra: ScopeAxis[AttributeMap]
|
||||||
):
|
):
|
||||||
|
// Since we use a uniqueness cache we can pre-compute the hashCode for free
|
||||||
|
// It is always going to be used at least once
|
||||||
override val hashCode = ScalaRunTime._hashCode(this)
|
override val hashCode = ScalaRunTime._hashCode(this)
|
||||||
|
|
||||||
def rescope(project: Reference): Scope = copy(project = Select(project))
|
def rescope(project: Reference): Scope = copy(project = Select(project))
|
||||||
|
|
@ -43,6 +45,9 @@ final case class Scope private (
|
||||||
end Scope
|
end Scope
|
||||||
|
|
||||||
object Scope:
|
object Scope:
|
||||||
|
// We use a global uniqueness cache to avoid duplicating Scope.
|
||||||
|
// At the time of writing, it divides the number of long-living instances by 15
|
||||||
|
// reducing the pressure on the heap, and speed up the loading.
|
||||||
private val uniquenessCache = TrieMap.empty[Scope, Scope]
|
private val uniquenessCache = TrieMap.empty[Scope, Scope]
|
||||||
|
|
||||||
def apply(
|
def apply(
|
||||||
|
|
|
||||||
|
|
@ -274,6 +274,8 @@ private[sbt] object Load {
|
||||||
finalTransforms(settings0)
|
finalTransforms(settings0)
|
||||||
}
|
}
|
||||||
val delegates = timed("Load.apply: config.delegates", log) {
|
val delegates = timed("Load.apply: config.delegates", log) {
|
||||||
|
// We use caching to avoid creating new Scope instances too many times
|
||||||
|
// Creating a new Scope is CPU expensive because of the uniqueness cache
|
||||||
Util.withCaching(config.delegates(loaded))
|
Util.withCaching(config.delegates(loaded))
|
||||||
}
|
}
|
||||||
val (cMap, data) = timed("Load.apply: Def.make(settings)...", log) {
|
val (cMap, data) = timed("Load.apply: Def.make(settings)...", log) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue