diff options
author | Martin Odersky <odersky@gmail.com> | 2012-07-12 22:47:55 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-14 12:09:32 +0200 |
commit | 73e61b8b0b9b8137af8ec9c6a101e991552a375e (patch) | |
tree | 0b97ee99a78e4cd12a3a50b7bd9af13ccf8e0993 /src | |
parent | 04f0b659efe8565c162b5933ace76e2adf00a16e (diff) | |
download | scala-73e61b8b0b9b8137af8ec9c6a101e991552a375e.tar.gz scala-73e61b8b0b9b8137af8ec9c6a101e991552a375e.tar.bz2 scala-73e61b8b0b9b8137af8ec9c6a101e991552a375e.zip |
Attempt #5 to optimize findMember.
Specific optimizations to findMember that have become possible because findMembers is its own function now.
Diffstat (limited to 'src')
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 105 |
1 files changed, 52 insertions, 53 deletions
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index afedf3460e..14011f3109 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -1034,7 +1034,6 @@ trait Types extends api.Types { self: SymbolTable => var excluded = excludedFlags | DEFERRED var continue = true var self: Type = null - var membertpe: Type = null while (continue) { continue = false val bcs0 = baseClasses @@ -1044,12 +1043,13 @@ trait Types extends api.Types { self: SymbolTable => var entry = decls.elems while (entry ne null) { val sym = entry.sym - if (sym hasAllFlags requiredFlags) { - val excl = sym.getFlag(excluded) + val flags = sym.flags + if ((flags & requiredFlags) == requiredFlags) { + val excl = flags & excluded if (excl == 0L && (// omit PRIVATE LOCALS unless selector class is contained in class owning the def. (bcs eq bcs0) || - !sym.isPrivateLocal || + (flags & PrivateLocal) != PrivateLocal || (bcs0.head.hasTransOwner(bcs.head)))) { if (members eq null) members = newScope var prevEntry = members.lookupEntry(sym.name) @@ -1118,61 +1118,60 @@ trait Types extends api.Types { self: SymbolTable => var bcs = bcs0 while (!bcs.isEmpty) { val decls = bcs.head.info.decls - var entry = - if (name eq nme.ANYNAME) decls.elems - else if ((fingerPrint & decls.fingerPrints) == 0) null - else decls.lookupEntry(name) - while (entry ne null) { - val sym = entry.sym - if (sym hasAllFlags requiredFlags) { - val excl = sym.getFlag(excluded) - if (excl == 0L && - (// omit PRIVATE LOCALS unless selector class is contained in class owning the def. - (bcs eq bcs0) || - !sym.isPrivateLocal || - (bcs0.head.hasTransOwner(bcs.head)))) { - if (name.isTypeName || stableOnly && sym.isStable) { - Statistics.popTimer(typeOpsStack, start) - if (suspension ne null) suspension foreach (_.suspended = false) - return sym - } else if (member eq NoSymbol) { - member = sym - } else if (members eq null) { - if ((member.name ne sym.name) || - !((member eq sym) || - (member.owner ne sym.owner) && - !sym.isPrivate && { - if (self eq null) self = this.narrow - if (membertpe eq null) membertpe = self.memberType(member) - (membertpe matches self.memberType(sym)) - })) { + if ((fingerPrint & decls.fingerPrints) != 0) { + var entry = decls.lookupEntry(name) + while (entry ne null) { + val sym = entry.sym + val flags = sym.flags + if ((flags & requiredFlags) == requiredFlags) { + val excl = flags & excluded + if (excl == 0L && + (// omit PRIVATE LOCALS unless selector class is contained in class owning the def. + (bcs eq bcs0) || + (flags & PrivateLocal) != PrivateLocal || + (bcs0.head.hasTransOwner(bcs.head)))) { + if (name.isTypeName || stableOnly && sym.isStable) { + Statistics.popTimer(typeOpsStack, start) + if (suspension ne null) suspension foreach (_.suspended = false) + return sym + } else if (member eq NoSymbol) { + member = sym + } else if (members eq null) { + if (!((member eq sym) || + (member.owner ne sym.owner) && + (flags & PRIVATE) == 0 && { + if (self eq null) self = this.narrow + if (membertpe eq null) membertpe = self.memberType(member) + (membertpe matches self.memberType(sym)) + })) { members = newScope members enter member members enter sym + } + } else { + var prevEntry = members.lookupEntry(sym.name) + var symtpe: Type = null + while ((prevEntry ne null) && + !((prevEntry.sym eq sym) || + (prevEntry.sym.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 + })) { + prevEntry = members lookupNextEntry prevEntry + } + if (prevEntry eq null) { + members enter sym + } } - } else { - var prevEntry = members.lookupEntry(sym.name) - var symtpe: Type = null - while ((prevEntry ne null) && - !((prevEntry.sym eq sym) || - (prevEntry.sym.owner ne sym.owner) && - !sym.hasFlag(PRIVATE) && { - if (self eq null) self = this.narrow - if (symtpe eq null) symtpe = self.memberType(sym) - self.memberType(prevEntry.sym) matches symtpe - })) { - prevEntry = members lookupNextEntry prevEntry - } - if (prevEntry eq null) { - members enter sym - } + } else if (excl == DEFERRED) { + continue = true } - } else if (excl == DEFERRED.toLong) { - continue = true } - } - entry = if (name == nme.ANYNAME) entry.next else decls lookupNextEntry entry - } // while (entry ne null) + entry = decls lookupNextEntry entry + } // while (entry ne null) + } // if (fingerPrint matches) // excluded = excluded | LOCAL bcs = if (name == nme.CONSTRUCTOR) Nil else bcs.tail } // while (!bcs.isEmpty) |