aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Hashable.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-01-27 16:06:41 +0100
committerMartin Odersky <odersky@gmail.com>2014-01-27 19:27:10 +0100
commit3617102b51df4625cbe37f6a3f71caf64ddf7211 (patch)
tree126395f38546b865c0a8e4928dfce1ef68f072fe /src/dotty/tools/dotc/core/Hashable.scala
parentc476171d838c55bbfe36856e73a470e826748acc (diff)
downloaddotty-3617102b51df4625cbe37f6a3f71caf64ddf7211.tar.gz
dotty-3617102b51df4625cbe37f6a3f71caf64ddf7211.tar.bz2
dotty-3617102b51df4625cbe37f6a3f71caf64ddf7211.zip
Selective caching of SelectionProtos and ViewProtos
We cache SelectionProtos if their "compat" parameter is "NoViewsAllowed". We always cache ViewProtos. That's important for implicit search, because this enables eligible refs to be better cached. To make this work, we add a case to WildApprox which massages SelectionProtos so they also get noViewsAllowed in the compat parameter.
Diffstat (limited to 'src/dotty/tools/dotc/core/Hashable.scala')
-rw-r--r--src/dotty/tools/dotc/core/Hashable.scala6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/Hashable.scala b/src/dotty/tools/dotc/core/Hashable.scala
index 2f55ef70a..fc3b7d0c7 100644
--- a/src/dotty/tools/dotc/core/Hashable.scala
+++ b/src/dotty/tools/dotc/core/Hashable.scala
@@ -35,8 +35,6 @@ trait Hashable {
protected final def identityHash = avoidNotCached(System.identityHashCode(this))
- protected final def avoidNotCached(h: Int) = if (h == NotCached) NotCachedAlt else h
-
private def finishHash(seed: Int, arity: Int, tp: Type): Int = {
val elemHash = tp.hash
if (elemHash == NotCached) return NotCached
@@ -89,4 +87,8 @@ trait Hashable {
protected final def doHash(x1: Any, tp2: Type, tps3: List[Type]): Int =
finishHash(hashing.mix(hashSeed, x1.hashCode), 1, tp2, tps3)
+
+ protected final def addDelta(hc: Int, delta: Int) = avoidNotCached(hc + delta)
+
+ private def avoidNotCached(h: Int) = if (h == NotCached) NotCachedAlt else h
}