aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/util/LRUCache.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-02-12 12:22:15 +0100
committerMartin Odersky <odersky@gmail.com>2014-02-12 17:47:19 +0100
commita6c50c1872cff7ffb20388c7ac2197d983085625 (patch)
tree235a3d388d858b7bbde50e1235c43e330a9c1e5e /src/dotty/tools/dotc/util/LRUCache.scala
parentca3ff285c4e8ecdb48eb09bb75fd05a0bc6ff487 (diff)
downloaddotty-a6c50c1872cff7ffb20388c7ac2197d983085625.tar.gz
dotty-a6c50c1872cff7ffb20388c7ac2197d983085625.tar.bz2
dotty-a6c50c1872cff7ffb20388c7ac2197d983085625.zip
Fixed a bug in LRUcache which prevented sizes >= 8.
Diffstat (limited to 'src/dotty/tools/dotc/util/LRUCache.scala')
-rw-r--r--src/dotty/tools/dotc/util/LRUCache.scala4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/util/LRUCache.scala b/src/dotty/tools/dotc/util/LRUCache.scala
index 5a485081f..4d0d82c99 100644
--- a/src/dotty/tools/dotc/util/LRUCache.scala
+++ b/src/dotty/tools/dotc/util/LRUCache.scala
@@ -1,6 +1,7 @@
package dotty.tools.dotc.util
import reflect.ClassTag
+import annotation.tailrec
/** A least-recently-used cache for Key -> Value computations
* It currently keeps the last 8 associations, but this can be
@@ -29,6 +30,7 @@ class LRUCache[Key >: Null : ClassTag, Value >: Null: ClassTag] {
* if key was not found.
*/
def lookup(key: Key): Value = {
+ @tailrec
def lookupNext(prev: Int, current: Int, nx: SixteenNibbles): Value = {
val follow = nx(current)
if (keys(current) == key) {
@@ -89,7 +91,7 @@ class LRUCache[Key >: Null : ClassTag, Value >: Null: ClassTag] {
object LRUCache {
/** The number of retained elements in the cache; must be at most 16. */
- val Retained = 8
+ val Retained = 16
/** The initial ring: 0 -> 1 -> ... -> 7 -> 0 */
val initialRing =