diff options
author | Paul Phillips <paulp@improving.org> | 2011-07-14 01:27:04 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-07-14 01:27:04 +0000 |
commit | 733669230a470b60c2ecc92c666f0871cecf22ef (patch) | |
tree | 70ee5f0e49e348e317bfd9db5d2230b433dada31 /src/compiler/scala/reflect/internal/Types.scala | |
parent | 5e49b4181976f20d28625008a775223dbf8e7f6e (diff) | |
download | scala-733669230a470b60c2ecc92c666f0871cecf22ef.tar.gz scala-733669230a470b60c2ecc92c666f0871cecf22ef.tar.bz2 scala-733669230a470b60c2ecc92c666f0871cecf22ef.zip |
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.
Diffstat (limited to 'src/compiler/scala/reflect/internal/Types.scala')
-rw-r--r-- | src/compiler/scala/reflect/internal/Types.scala | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index bb5608917b..34150069ad 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -9,8 +9,6 @@ package internal import scala.collection.{ mutable, immutable } import scala.ref.WeakReference import mutable.ListBuffer -//import ast.TreeGen -//import util.{ Position, NoPosition } import Flags._ import scala.util.control.ControlThrowable import scala.annotation.tailrec @@ -105,6 +103,9 @@ trait Types extends api.Types { self: SymbolTable => private type UndoLog = List[(TypeVar, TypeConstraint)] private[scala] var log: UndoLog = List() + // register with the auto-clearing cache manager + perRunCaches.recordCache(this) + /** Undo all changes to constraints to type variables upto `limit`. */ private def undoTo(limit: UndoLog) { while ((log ne limit) && log.nonEmpty) { @@ -123,6 +124,7 @@ trait Types extends api.Types { self: SymbolTable => log = Nil } + def size = log.size // `block` should not affect constraints on typevars def undo[T](block: => T): T = { @@ -149,7 +151,7 @@ trait Types extends api.Types { self: SymbolTable => * It makes use of the fact that these two operations depend only on the parents, * not on the refinement. */ - val intersectionWitness = new mutable.WeakHashMap[List[Type], WeakReference[Type]] + val intersectionWitness = perRunCaches.newWeakMap[List[Type], WeakReference[Type]]() //private object gen extends { // val global : Types.this.type = Types.this |