aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Contexts.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-01-26 18:44:34 +0100
committerMartin Odersky <odersky@gmail.com>2014-01-26 18:52:33 +0100
commitaafa0c16dbf95fb880573dea6f9ee6db02470740 (patch)
treeaa738e536b5032261315cd2453f0393b7657b602 /src/dotty/tools/dotc/core/Contexts.scala
parent5b69fbbe68705ece7d892cbda555191853f1c5be (diff)
downloaddotty-aafa0c16dbf95fb880573dea6f9ee6db02470740.tar.gz
dotty-aafa0c16dbf95fb880573dea6f9ee6db02470740.tar.bz2
dotty-aafa0c16dbf95fb880573dea6f9ee6db02470740.zip
New treatment of uniques
To avoid to always create a type before checking its uniqueness we specialize on the three most common categories: RefinedTypes, TypeBounds and NamedTypes. Each category gets its own uniques map. Hashing is disentangled from Types. The new treatement seems to give some improvement (2-5%?) but not much.
Diffstat (limited to 'src/dotty/tools/dotc/core/Contexts.scala')
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index 8c2e0fbb3..d9116d2b6 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -10,6 +10,7 @@ import Types._
import Symbols._
import Scopes._
import NameOps._
+import Uniques._
import SymDenotations._
import util.Positions._
import ast.Trees._
@@ -427,7 +428,20 @@ object Contexts {
override def hash(x: Type): Int = x.hash
}
- private[dotc] def uniquesSize = uniques.size
+ /** A table for hash consing unique refined types */
+ private[core] val uniqueRefinedTypes = new RefinedUniques
+
+ /** A table for hash consing unique named types */
+ private[core] val uniqueNamedTypes = new NamedTypeUniques
+
+ /** A table for hash consing unique type bounds */
+ private[core] val uniqueTypeBounds = new TypeBoundsUniques
+
+ private def uniqueMaps = List(uniques, uniqueRefinedTypes, uniqueNamedTypes, 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
/** The number of recursive invocation of underlying on a NamedType
* during a controlled operation.
@@ -475,7 +489,7 @@ object Contexts {
private final val InitialSuperIdsSize = 4096
/** Initial capacity of uniques HashMap */
- private[core] final val initialUniquesCapacity = 50000
+ private[core] final val initialUniquesCapacity = 40000
/** How many recursive calls to NamedType#underlying are performed before
* logging starts.