mirror of https://github.com/sbt/sbt.git
Optimise scope intersection for GlobalScope
This commit is contained in:
parent
decd323b64
commit
962f0bad76
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
import Types._
|
import Types._
|
||||||
|
|
||||||
sealed trait Settings[Scope]
|
sealed trait Settings[Scope]
|
||||||
{
|
{
|
||||||
|
|
@ -291,6 +291,11 @@ trait Init[Scope]
|
||||||
} else ""
|
} else ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Intersects two scopes, returning the more specific one if they intersect, or None otherwise.
|
||||||
|
* Not implemented here because we want to optimise for Scope.GlobalScope which is inaccessible here. */
|
||||||
|
private[sbt] def intersect(s1: Scope, s2: Scope)(implicit delegates: Scope => Seq[Scope]): Option[Scope] = ???
|
||||||
|
|
||||||
private[this] def deriveAndLocal(init: Seq[Setting[_]])(implicit delegates: Scope => Seq[Scope], scopeLocal: ScopeLocal): Seq[Setting[_]] =
|
private[this] def deriveAndLocal(init: Seq[Setting[_]])(implicit delegates: Scope => Seq[Scope], scopeLocal: ScopeLocal): Seq[Setting[_]] =
|
||||||
{
|
{
|
||||||
import collection.mutable
|
import collection.mutable
|
||||||
|
|
@ -361,10 +366,6 @@ trait Init[Scope]
|
||||||
val scope = sk.scope
|
val scope = sk.scope
|
||||||
def localAndDerived(d: Derived): Seq[Setting[_]] = {
|
def localAndDerived(d: Derived): Seq[Setting[_]] = {
|
||||||
def definingScope = d.setting.key.scope
|
def definingScope = d.setting.key.scope
|
||||||
def intersect(s1: Scope, s2: Scope): Option[Scope] =
|
|
||||||
if (delegates(s1).contains(s2)) Some(s1) // s1 is more specific
|
|
||||||
else if (delegates(s2).contains(s1)) Some(s2) // s2 is more specific
|
|
||||||
else None
|
|
||||||
val outputScope = intersect(scope, definingScope)
|
val outputScope = intersect(scope, definingScope)
|
||||||
outputScope collect { case s if !d.inScopes.contains(s) && d.setting.filter(s) =>
|
outputScope collect { case s if !d.inScopes.contains(s) && d.setting.filter(s) =>
|
||||||
val local = d.dependencies.flatMap(dep => scopeLocal(ScopedKey(s, dep)))
|
val local = d.dependencies.flatMap(dep => scopeLocal(ScopedKey(s, dep)))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue