@@ -18,6 +18,7 @@ import Variances.Variance
1818import annotation .tailrec
1919import util .SimpleIdentityMap
2020import util .Stats
21+ import util .UniqList
2122import java .util .WeakHashMap
2223import scala .util .control .NonFatal
2324import config .Config
@@ -2231,16 +2232,16 @@ object SymDenotations {
22312232 }
22322233 }
22332234
2234- def memberNames (keepOnly : NameFilter )(implicit onBehalf : MemberNames , ctx : Context ): Set [Name ] =
2235+ def memberNames (keepOnly : NameFilter )(implicit onBehalf : MemberNames , ctx : Context ): UniqList [Name ] =
22352236 if (this .is(PackageClass ) || ! Config .cacheMemberNames)
22362237 computeMemberNames(keepOnly) // don't cache package member names; they might change
22372238 else {
22382239 if (! memberNamesCache.isValid) memberNamesCache = MemberNames .newCache()
22392240 memberNamesCache(keepOnly, this )
22402241 }
22412242
2242- def computeMemberNames (keepOnly : NameFilter )(implicit onBehalf : MemberNames , ctx : Context ): Set [Name ] = {
2243- var names = Set [Name ]()
2243+ def computeMemberNames (keepOnly : NameFilter )(implicit onBehalf : MemberNames , ctx : Context ): UniqList [Name ] = {
2244+ val names = new UniqList . Builder [Name ]
22442245 def maybeAdd (name : Name ) = if (keepOnly(thisType, name)) names += name
22452246 try {
22462247 for (p <- parentSyms if p.isClass)
@@ -2253,7 +2254,7 @@ object SymDenotations {
22532254 else info.decls.iterator.filter(_.isOneOf(GivenOrImplicitVal ))
22542255 else info.decls.iterator
22552256 for (sym <- ownSyms) maybeAdd(sym.name)
2256- names
2257+ names.result
22572258 }
22582259 catch {
22592260 case ex : Throwable =>
@@ -2466,10 +2467,10 @@ object SymDenotations {
24662467 end computeMembersNamed
24672468
24682469 /** The union of the member names of the package and the package object */
2469- override def memberNames (keepOnly : NameFilter )(implicit onBehalf : MemberNames , ctx : Context ): Set [Name ] = {
2470- def recur (pobjs : List [ClassDenotation ], acc : Set [Name ]): Set [Name ] = pobjs match {
2470+ override def memberNames (keepOnly : NameFilter )(implicit onBehalf : MemberNames , ctx : Context ): UniqList [Name ] = {
2471+ def recur (pobjs : List [ClassDenotation ], acc : UniqList [Name ]): UniqList [Name ] = pobjs match {
24712472 case pcls :: pobjs1 =>
2472- recur(pobjs1, acc.union( pcls.memberNames(keepOnly) ))
2473+ recur(pobjs1, acc | pcls.memberNames(keepOnly))
24732474 case nil =>
24742475 acc
24752476 }
@@ -2752,7 +2753,7 @@ object SymDenotations {
27522753 /** A cache for sets of member names, indexed by a NameFilter */
27532754 trait MemberNames extends InheritedCache {
27542755 def apply (keepOnly : NameFilter , clsd : ClassDenotation )
2755- (implicit onBehalf : MemberNames , ctx : Context ): Set [Name ]
2756+ (implicit onBehalf : MemberNames , ctx : Context ): UniqList [Name ]
27562757 }
27572758
27582759 object MemberNames {
@@ -2813,7 +2814,7 @@ object SymDenotations {
28132814 }
28142815
28152816 private class MemberNamesImpl (createdAt : Period ) extends InheritedCacheImpl (createdAt) with MemberNames {
2816- private var cache : SimpleIdentityMap [NameFilter , Set [Name ]] = SimpleIdentityMap .empty
2817+ private var cache : SimpleIdentityMap [NameFilter , UniqList [Name ]] = SimpleIdentityMap .empty
28172818
28182819 final def isValid (using Context ): Boolean =
28192820 cache != null && isValidAt(ctx.phase)
0 commit comments