diff options
author | Paul Phillips <paulp@improving.org> | 2012-04-24 07:51:19 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-04-25 09:09:29 -0700 |
commit | c22ec635c75170d1ac1cb0074e532b4186eed845 (patch) | |
tree | 44713230e43a29b34bb87a41cc1719334fe32391 /src/compiler/scala/tools/nsc/interpreter/IMain.scala | |
parent | 5cf9499731255078de62c8f3704fa596b564bf0e (diff) | |
download | scala-c22ec635c75170d1ac1cb0074e532b4186eed845.tar.gz scala-c22ec635c75170d1ac1cb0074e532b4186eed845.tar.bz2 scala-c22ec635c75170d1ac1cb0074e532b4186eed845.zip |
Some long overdue conveniences.
Not just conveniences though. One of the clearest statements made
by profiling is that collections methods of the form of the enclosed
flatCollect are materially faster than the alternatives.
Diffstat (limited to 'src/compiler/scala/tools/nsc/interpreter/IMain.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/interpreter/IMain.scala | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index 3d77344091..a9c2ce0d09 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -369,7 +369,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends def flatName(id: String) = optFlatName(id) getOrElse id def optFlatName(id: String) = requestForIdent(id) map (_ fullFlatName id) - def allDefinedNames = definedNameMap.keys.toList sortBy (_.toString) + def allDefinedNames = definedNameMap.keys.toList.sorted def pathToType(id: String): String = pathToName(newTypeName(id)) def pathToTerm(id: String): String = pathToName(newTermName(id)) def pathToName(name: Name): String = { @@ -1007,9 +1007,8 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends def lookupTypeOf(name: Name) = typeOf.getOrElse(name, typeOf(global.encode(name.toString))) def simpleNameOfType(name: TypeName) = (compilerTypeOf get name) map (_.typeSymbol.simpleName) - private def typeMap[T](f: Type => T): Map[Name, T] = { - termNames ++ typeNames map (x => x -> f(cleanMemberDecl(resultSymbol, x))) toMap - } + private def typeMap[T](f: Type => T) = + mapFrom[Name, Name, T](termNames ++ typeNames)(x => f(cleanMemberDecl(resultSymbol, x))) /** Types of variables defined by this request. */ lazy val compilerTypeOf = typeMap[Type](x => x) withDefaultValue NoType @@ -1024,8 +1023,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends typeNames.map(x => x -> compilerTypeOf(x).typeSymbol) ).toMap[Name, Symbol] withDefaultValue NoSymbol - lazy val typesOfDefinedTerms: Map[Name, Type] = - termNames map (x => x -> applyToResultMember(x, _.tpe)) toMap + lazy val typesOfDefinedTerms = mapFrom[Name, Name, Type](termNames)(x => applyToResultMember(x, _.tpe)) /** load and run the code using reflection */ def loadAndRun: (String, Boolean) = { |