aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Contexts.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-02-24 13:21:24 +0100
committerMartin Odersky <odersky@gmail.com>2014-02-24 18:56:48 +0100
commitcdeafeafd252b20a0df5440e0420211af95e0cdc (patch)
treea2112ebe760b54d923f20305f2c29429d7f7cf6b /src/dotty/tools/dotc/core/Contexts.scala
parent91e74ee45c8cedac279ec66f8277c94d05f2f2e3 (diff)
downloaddotty-cdeafeafd252b20a0df5440e0420211af95e0cdc.tar.gz
dotty-cdeafeafd252b20a0df5440e0420211af95e0cdc.tar.bz2
dotty-cdeafeafd252b20a0df5440e0420211af95e0cdc.zip
Resetting uniques and hashset reorg.
Uniques are now cleared after each run. Also, HashSets get a more standard API, without a label, but with configurable load factor.
Diffstat (limited to 'src/dotty/tools/dotc/core/Contexts.scala')
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index 859475cd5..cfaa3720f 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -422,7 +422,7 @@ object Contexts {
// Types state
/** A table for hash consing unique types */
- private[core] val uniques = new util.HashSet[Type]("uniques", initialUniquesCapacity) {
+ private[core] val uniques = new util.HashSet[Type](initialUniquesCapacity) {
override def hash(x: Type): Int = x.hash
}
@@ -435,11 +435,14 @@ object Contexts {
/** A table for hash consing unique type bounds */
private[core] val uniqueTypeBounds = new TypeBoundsUniques
- private def uniqueMaps = List(uniques, uniqueRefinedTypes, uniqueNamedTypes, uniqueTypeBounds)
+ private def uniqueSets = Map(
+ "uniques" -> uniques,
+ "uniqueRefinedTypes" -> uniqueRefinedTypes,
+ "uniqueNamedTypes" -> uniqueNamedTypes,
+ "uniqueTypeBounds" -> uniqueTypeBounds)
/** A map that associates label and size of all uniques sets */
- def uniquesSize: Map[String, Int] =
- uniqueMaps.map(m => m.label -> m.size).toMap
+ def uniquesSizes: Map[String, Int] = uniqueSets.mapValues(_.size)
/** The number of recursive invocation of underlying on a NamedType
* during a controlled operation.
@@ -465,6 +468,10 @@ object Contexts {
/** Should warnings and errors containing non-sensical strings be suppressed? */
private[dotc] var suppressNonSensicalErrors = true
+
+ def reset() = {
+ for ((_, set) <- uniqueSets) set.clear()
+ }
}
object Context {