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/Implicits.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/compiler/scala/tools/nsc/typechecker/Implicits.scala') diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 29ca9f4a70..c0e78d716c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -13,7 +13,7 @@ package typechecker import annotation.tailrec import scala.collection.{ mutable, immutable } -import mutable.{ HashMap, LinkedHashMap, ListBuffer } +import mutable.{ LinkedHashMap, ListBuffer } import scala.util.matching.Regex import symtab.Flags._ import util.Statistics._ @@ -83,7 +83,7 @@ trait Implicits { private type InfoMap = LinkedHashMap[Symbol, List[ImplicitInfo]] // A map from class symbols to their associated implicits private val implicitsCache = new LinkedHashMap[Type, Infoss] private val infoMapCache = new LinkedHashMap[Symbol, InfoMap] - private val improvesCache = new HashMap[(ImplicitInfo, ImplicitInfo), Boolean] + private val improvesCache = perRunCaches.newMap[(ImplicitInfo, ImplicitInfo), Boolean]() def resetImplicits() { implicitsCache.clear() @@ -175,7 +175,7 @@ trait Implicits { /** An extractor for types of the form ? { name: ? } */ object HasMember { - private val hasMemberCache = new mutable.HashMap[Name, Type] + private val hasMemberCache = perRunCaches.newMap[Name, Type]() def apply(name: Name): Type = hasMemberCache.getOrElseUpdate(name, memberWildcardType(name, WildcardType)) def unapply(pt: Type): Option[Name] = pt match { case RefinedType(List(WildcardType), decls) => -- cgit v1.2.3