Merge pull request #5002 from xuwei-k/use-Vector-instead-of-List

use Vector instead of List. avoid O(n) append
This commit is contained in:
Ethan Atkins 2019-08-29 09:24:09 -07:00 committed by GitHub
commit 3f6fa7ee87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -228,10 +228,10 @@ trait Init[ScopeType] {
((IMap.empty: ScopedMap) /: init)((m, s) => add(m, s))
def add[T](m: ScopedMap, s: Setting[T]): ScopedMap =
m.mapValue[T](s.key, Nil, ss => append(ss, s))
m.mapValue[T](s.key, Vector.empty[Setting[T]], ss => append(ss, s))
def append[T](ss: Seq[Setting[T]], s: Setting[T]): Seq[Setting[T]] =
if (s.definitive) s :: Nil else ss :+ s
if (s.definitive) Vector(s) else ss :+ s
def addLocal(init: Seq[Setting[_]])(implicit scopeLocal: ScopeLocal): Seq[Setting[_]] =
init.par.map(_.dependencies flatMap scopeLocal).toVector.flatten ++ init