From 962f0bad763ea57aa0bf39a51d329e3f355bafdc Mon Sep 17 00:00:00 2001 From: Dan Sanduleac Date: Wed, 18 Dec 2013 10:52:45 +0000 Subject: [PATCH] Optimise scope intersection for GlobalScope --- util/collection/src/main/scala/sbt/Settings.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/util/collection/src/main/scala/sbt/Settings.scala b/util/collection/src/main/scala/sbt/Settings.scala index af56cb4f8..bc88520f1 100644 --- a/util/collection/src/main/scala/sbt/Settings.scala +++ b/util/collection/src/main/scala/sbt/Settings.scala @@ -3,7 +3,7 @@ */ package sbt - import Types._ +import Types._ sealed trait Settings[Scope] { @@ -291,6 +291,11 @@ trait Init[Scope] } 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[_]] = { import collection.mutable @@ -361,10 +366,6 @@ trait Init[Scope] val scope = sk.scope def localAndDerived(d: Derived): Seq[Setting[_]] = { 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) outputScope collect { case s if !d.inScopes.contains(s) && d.setting.filter(s) => val local = d.dependencies.flatMap(dep => scopeLocal(ScopedKey(s, dep)))