From 41f4497cc57f5e010df10a9f5a98c9815c1c36fd Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 12 Jul 2012 15:36:28 +0200 Subject: [PATCH] Attempt #2 to optimize findMember --- src/compiler/scala/tools/nsc/Driver.scala | 4 +++- src/compiler/scala/tools/nsc/Main.scala | 6 ++---- src/reflect/scala/reflect/internal/Types.scala | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/compiler/scala/tools/nsc/Driver.scala b/src/compiler/scala/tools/nsc/Driver.scala index 0051c3bdec37..15e2929ff171 100644 --- a/src/compiler/scala/tools/nsc/Driver.scala +++ b/src/compiler/scala/tools/nsc/Driver.scala @@ -1,10 +1,12 @@ package scala.tools.nsc import scala.tools.nsc.reporters.{Reporter, ConsoleReporter} -import Properties.{ versionString, copyrightString } +import Properties.{ versionString, copyrightString, residentPromptString } import scala.reflect.internal.util.{ BatchSourceFile, FakePos } abstract class Driver { + + val prompt = residentPromptString val versionMsg = "Scala compiler " + versionString + " -- " + diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala index 19c872b6d311..8b7e76e9942f 100644 --- a/src/compiler/scala/tools/nsc/Main.scala +++ b/src/compiler/scala/tools/nsc/Main.scala @@ -12,15 +12,13 @@ import scala.tools.nsc.interactive.{ RefinedBuildManager, SimpleBuildManager } import scala.tools.nsc.io.AbstractFile import scala.tools.nsc.reporters.{Reporter, ConsoleReporter} import scala.reflect.internal.util.{ BatchSourceFile, FakePos } //{Position} -import Properties.{ versionString, copyrightString, residentPromptString, msilLibPath } +import Properties.msilLibPath /** The main class for NSC, a compiler for the programming - * language Scala. + * language Scala. */ object Main extends Driver with EvalLoop { - val prompt = residentPromptString - def resident(compiler: Global) { loop { line => val args = line.split(' ').toList diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 191981efeffb..8477bdaf01ff 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -1053,7 +1053,7 @@ trait Types extends api.Types { self: SymbolTable => while (!bcs.isEmpty) { val decls = bcs.head.info.decls var entry = - if (name == nme.ANYNAME) decls.elems + if (name eq nme.ANYNAME) decls.elems else if ((fingerPrint & decls.fingerPrints) == 0) null else decls.lookupEntry(name) while (entry ne null) { @@ -1069,12 +1069,12 @@ trait Types extends api.Types { self: SymbolTable => Statistics.popTimer(typeOpsStack, start) if (suspension ne null) suspension foreach (_.suspended = false) return sym - } else if (member == NoSymbol) { + } else if (member eq NoSymbol) { member = sym } else if (members eq null) { - if (member.name != sym.name || - !(member == sym || - member.owner != sym.owner && + 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) @@ -1088,8 +1088,8 @@ trait Types extends api.Types { self: SymbolTable => var prevEntry = members.lookupEntry(sym.name) var symtpe: Type = null while ((prevEntry ne null) && - !(prevEntry.sym == sym || - prevEntry.sym.owner != sym.owner && + !((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)