diff options
author | Martin Odersky <odersky@gmail.com> | 2012-08-17 15:40:20 +0200 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2012-08-20 08:11:08 +0100 |
commit | 3b7c730212fa4653c12ff2681cb67369101ce2c2 (patch) | |
tree | 4889331b46a80081dfae9b737c1405297b7702b4 /src/reflect | |
parent | 2a2d92352c3773a6a768c2f83714a3902d327003 (diff) | |
download | scala-3b7c730212fa4653c12ff2681cb67369101ce2c2.tar.gz scala-3b7c730212fa4653c12ff2681cb67369101ce2c2.tar.bz2 scala-3b7c730212fa4653c12ff2681cb67369101ce2c2.zip |
Specialize hashCode in TypeRef from the generic MurmurHashCode3 implementation.
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index fcba682ad5..78b595bc13 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -1266,7 +1266,8 @@ trait Types extends api.Types { self: SymbolTable => * A type that can be passed to unique(..) and be stored in the uniques map. */ abstract class UniqueType extends Type with Product { - final override val hashCode = scala.runtime.ScalaRunTime._hashCode(this) + final override val hashCode = computeHashCode + protected def computeHashCode = scala.runtime.ScalaRunTime._hashCode(this) } /** A base class for types that defer some operations @@ -2341,6 +2342,19 @@ trait Types extends api.Types { self: SymbolTable => private[reflect] var baseTypeSeqCache: BaseTypeSeq = _ private[reflect] var baseTypeSeqPeriod = NoPeriod private var normalized: Type = _ + + //OPT specialize hashCode + override final def computeHashCode = { + import scala.util.hashing.MurmurHash3._ + val hasArgs = args.nonEmpty + var h = productSeed + h = mix(h, pre.hashCode) + h = mix(h, sym.hashCode) + if (hasArgs) + finalizeHash(mix(h, args.hashCode), 3) + else + finalizeHash(h, 2) + } // @M: propagate actual type params (args) to `tp`, by replacing // formal type parameters with actual ones. If tp is higher kinded, |