diff options
author | Martin Odersky <odersky@gmail.com> | 2014-02-19 17:03:34 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-02-21 18:42:50 +0100 |
commit | d0568c1a5717a6adc22f74b93552394a9c4c586f (patch) | |
tree | 89157d809a433b99a72122b4afc12485c6720231 /src | |
parent | f2564f5ec6bd875b833ee3c0f509f3200f2e2362 (diff) | |
download | dotty-d0568c1a5717a6adc22f74b93552394a9c4c586f.tar.gz dotty-d0568c1a5717a6adc22f74b93552394a9c4c586f.tar.bz2 dotty-d0568c1a5717a6adc22f74b93552394a9c4c586f.zip |
Performance improvement in LRUCache
Use eq for key comparisons in LRUCache.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/util/LRUCache.scala | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/util/LRUCache.scala b/src/dotty/tools/dotc/util/LRUCache.scala index 4d0d82c99..5f53e81c4 100644 --- a/src/dotty/tools/dotc/util/LRUCache.scala +++ b/src/dotty/tools/dotc/util/LRUCache.scala @@ -15,7 +15,7 @@ import annotation.tailrec * get promoted to be first in the queue. Elements are evicted * at the `last` position. */ -class LRUCache[Key >: Null : ClassTag, Value >: Null: ClassTag] { +class LRUCache[Key >: Null <: AnyRef : ClassTag, Value >: Null: ClassTag] { import LRUCache._ val keys = new Array[Key](Retained) val values = new Array[Value](Retained) @@ -33,7 +33,7 @@ class LRUCache[Key >: Null : ClassTag, Value >: Null: ClassTag] { @tailrec def lookupNext(prev: Int, current: Int, nx: SixteenNibbles): Value = { val follow = nx(current) - if (keys(current) == key) { + if (keys(current) eq key) { // arrange so that found element is at position `first`. if (current == last) last = prev else if (prev != last) { |