diff options
author | Martin Odersky <odersky@gmail.com> | 2012-07-12 23:18:20 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-14 12:09:32 +0200 |
commit | e94252ea30032fa4e2f1f341c8db7fb38977618e (patch) | |
tree | e45ed5c7219031ba2ab36da1cb14f962ce0e370b /src | |
parent | 73e61b8b0b9b8137af8ec9c6a101e991552a375e (diff) | |
download | scala-e94252ea30032fa4e2f1f341c8db7fb38977618e.tar.gz scala-e94252ea30032fa4e2f1f341c8db7fb38977618e.tar.bz2 scala-e94252ea30032fa4e2f1f341c8db7fb38977618e.zip |
Attemmpt #6 to optimize findMember
Replace scope by ::-list, where new elements are added at the end.
Diffstat (limited to 'src')
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 14011f3109..f8bb543cff 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -1017,7 +1017,7 @@ trait Types extends api.Types { self: SymbolTable => if (alts.isEmpty) sym else (baseClasses.head.newOverloaded(this, alts)) } - + def findMembers(excludedFlags: Long, requiredFlags: Long): List[Symbol] = { // if this type contains type variables, put them to sleep for a while -- don't just wipe them out by // replacing them by the corresponding type parameter, as that messes up (e.g.) type variables in type refinements @@ -1040,7 +1040,7 @@ trait Types extends api.Types { self: SymbolTable => var bcs = bcs0 while (!bcs.isEmpty) { val decls = bcs.head.info.decls - var entry = decls.elems + var entry = decls.elems while (entry ne null) { val sym = entry.sym val flags = sym.flags @@ -1105,7 +1105,8 @@ trait Types extends api.Types { self: SymbolTable => val start = Statistics.pushTimer(typeOpsStack, findMemberNanos) //Console.println("find member " + name.decode + " in " + this + ":" + this.baseClasses)//DEBUG - var members: Scope = null + var members: List[Symbol] = null + var lastM: ::[Symbol] = null var member: Symbol = NoSymbol var excluded = excludedFlags | DEFERRED var continue = true @@ -1144,25 +1145,26 @@ trait Types extends api.Types { self: SymbolTable => if (membertpe eq null) membertpe = self.memberType(member) (membertpe matches self.memberType(sym)) })) { - members = newScope - members enter member - members enter sym + lastM = new ::(sym, null) + members = member :: lastM } } else { - var prevEntry = members.lookupEntry(sym.name) + var others = members var symtpe: Type = null - while ((prevEntry ne null) && - !((prevEntry.sym eq sym) || - (prevEntry.sym.owner ne sym.owner) && + while ((others ne null) && + !((others.head eq sym) || + (others.head.owner ne sym.owner) && (flags & PRIVATE) == 0 && { if (self eq null) self = this.narrow if (symtpe eq null) symtpe = self.memberType(sym) - self.memberType(prevEntry.sym) matches symtpe + self.memberType(others.head) matches symtpe })) { - prevEntry = members lookupNextEntry prevEntry + others = others.tail } - if (prevEntry eq null) { - members enter sym + if (others eq null) { + val lastM1 = new ::(sym, null) + lastM.tl = lastM1 + lastM = lastM1 } } } else if (excl == DEFERRED) { @@ -1184,10 +1186,11 @@ trait Types extends api.Types { self: SymbolTable => member } else { Statistics.incCounter(multMemberCount) - baseClasses.head.newOverloaded(this, members.toList) + lastM.tl = Nil + baseClasses.head.newOverloaded(this, members) } } - + /** The (existential or otherwise) skolems and existentially quantified variables which are free in this type */ def skolemsExceptMethodTypeParams: List[Symbol] = { var boundSyms: List[Symbol] = List() |