From d906455aedfc0f6184c8d07a3f9a63f8766bf0ba Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Tue, 25 Jan 2011 22:14:02 -0500 Subject: [PATCH] split load-time project structure scope resolution into two phases first phase resolves referenced build URIs as each build is loaded second phase resolves references without an explicit project ID (this requires the whole structure to be known and this isn't available during the first phase) setting resolution is unchanged (done after both phases) --- util/collection/Settings.scala | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/util/collection/Settings.scala b/util/collection/Settings.scala index c779274e6..6c9532a0d 100644 --- a/util/collection/Settings.scala +++ b/util/collection/Settings.scala @@ -4,8 +4,6 @@ package sbt import Types._ - import annotation.tailrec - import collection.mutable sealed trait Settings[Scope] { @@ -98,9 +96,12 @@ trait Init[Scope] def delegate(sMap: ScopedMap)(implicit delegates: Scope => Seq[Scope]): ScopedMap = { - val md = memoDelegates(delegates) - def refMap(refKey: ScopedKey[_]) = new (ScopedKey ~> ScopedKey) { def apply[T](k: ScopedKey[T]) = delegateForKey(sMap, k, md(k.scope), refKey) } - val f = new (SettingSeq ~> SettingSeq) { def apply[T](ks: Seq[Setting[T]]) = ks.map{ s => s mapReferenced refMap(s.key) } } + def refMap(refKey: ScopedKey[_]) = new (ScopedKey ~> ScopedKey) { def apply[T](k: ScopedKey[T]) = + delegateForKey(sMap, k, delegates(k.scope), refKey) + } + val f = new (SettingSeq ~> SettingSeq) { def apply[T](ks: Seq[Setting[T]]) = + ks.map{ s => s mapReferenced refMap(s.key) } + } sMap mapValues f } private[this] def delegateForKey[T](sMap: ScopedMap, k: ScopedKey[T], scopes: Seq[Scope], refKey: ScopedKey[_]): ScopedKey[T] = @@ -121,12 +122,6 @@ trait Init[Scope] private[this] def applyInits(ordered: Seq[Compiled])(implicit delegates: Scope => Seq[Scope]): Settings[Scope] = (empty /: ordered){ (m, comp) => comp.eval(m) } - private[this] def memoDelegates(implicit delegates: Scope => Seq[Scope]): Scope => Seq[Scope] = - { - val dcache = new mutable.HashMap[Scope, Seq[Scope]] - (scope: Scope) => dcache.getOrElseUpdate(scope, delegates(scope)) - } - private[this] def applySetting[T](map: Settings[Scope], setting: Setting[T]): Settings[Scope] = { def execK[HL <: HList, M[_]](a: KApply[HL, M, T]) =