From 733669230a470b60c2ecc92c666f0871cecf22ef Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 14 Jul 2011 01:27:04 +0000 Subject: Adding some Sets/Maps to perRunCaches, and elim... Adding some Sets/Maps to perRunCaches, and eliminating ambiguously named imports. Did a tour of the compiler adding a few longer-lived mutable structures to the per-run cache clearing mechanism. Some of these were not a big threat, but there is (almost) literally no cost to tracking them and the fewer mutable structures which are created "lone wolf style" the easier it is to spot the one playing by his own rules. While I was at it I followed through on long held ambition to eliminate the importing of highly ambiguous names like "Map" and "HashSet" from the mutable and immutable packages. I didn't quite manage elimination but it's pretty close. Something potentially as pernicious which I didn't do much about is this import: import scala.collection._ Imagine coming across that one on lines 407 and 474 of a 1271 file. That's not cool. Some poor future programmer will be on line 1100 and use "Map[A, B]" in some function and only after the product has shipped will it be discovered that the signature is wrong and the rocket will now be crashing into the mountainside straightaway. No review. --- src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala') diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala index a8c3a13646..c8e2b6fca4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala @@ -8,7 +8,7 @@ package typechecker import scala.tools.nsc.symtab.Flags._ import scala.collection.mutable -import mutable.{ HashMap, HashSet, ListBuffer } +import mutable.ListBuffer import util.returning abstract class TreeCheckers extends Analyzer { @@ -33,12 +33,13 @@ abstract class TreeCheckers extends Analyzer { /** This is a work in progress, don't take it too seriously. */ object SymbolTracker extends Traverser { - type PhaseMap = HashMap[Symbol, List[Tree]] - val maps: ListBuffer[(Phase, PhaseMap)] = ListBuffer() + type PhaseMap = mutable.HashMap[Symbol, List[Tree]] + + val maps = ListBuffer[(Phase, PhaseMap)]() def prev = maps.init.last._2 def latest = maps.last._2 - val defSyms = new HashMap[Symbol, List[DefTree]] - val newSyms = new HashSet[Symbol] + val defSyms = mutable.HashMap[Symbol, List[DefTree]]() + val newSyms = mutable.HashSet[Symbol]() val movedMsgs = new ListBuffer[String] def sortedNewSyms = newSyms.toList.distinct sortBy (_.name.toString) @@ -110,7 +111,7 @@ abstract class TreeCheckers extends Analyzer { } } - lazy val tpeOfTree = new HashMap[Tree, Type] + lazy val tpeOfTree = mutable.HashMap[Tree, Type]() def posstr(p: Position) = try p.source.path + ":" + p.line -- cgit v1.2.3