summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorstepancheg <stepancheg@epfl.ch>2008-06-09 18:50:31 +0000
committerstepancheg <stepancheg@epfl.ch>2008-06-09 18:50:31 +0000
commit9ba40ca89095dfc6713e09b4e788410a61d78d81 (patch)
treeea2e02d6373c535474c69c4066370bd027fab622 /src
parent02271ecb5e0c10cef290090a08b4a7b6bcfd30d2 (diff)
downloadscala-9ba40ca89095dfc6713e09b4e788410a61d78d81.tar.gz
scala-9ba40ca89095dfc6713e09b4e788410a61d78d81.tar.bz2
scala-9ba40ca89095dfc6713e09b4e788410a61d78d81.zip
speed up HashTable by replacing BoxedAnyArray w...
speed up HashTable by replacing BoxedAnyArray with raw array
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/collection/immutable/HashMap.scala4
-rw-r--r--src/library/scala/collection/mutable/HashTable.scala14
2 files changed, 9 insertions, 9 deletions
diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala
index 248b4b2714..651900a5d2 100644
--- a/src/library/scala/collection/immutable/HashMap.scala
+++ b/src/library/scala/collection/immutable/HashMap.scala
@@ -143,10 +143,10 @@ class HashMap[A, B] extends Map[A,B] with mutable.HashTable[A] {
}
val ltable = last.table
val s = ltable.length
- table = new Array[Entry](s)
+ table = new Array[mutable.HashEntry[A, Entry]](s)
var i = 0
while (i < s) {
- table(i) = copy(ltable(i))
+ table(i) = copy(ltable(i).asInstanceOf[Entry])
i += 1
}
tableSize = last.tableSize
diff --git a/src/library/scala/collection/mutable/HashTable.scala b/src/library/scala/collection/mutable/HashTable.scala
index fb9ce91c58..20e8f249ff 100644
--- a/src/library/scala/collection/mutable/HashTable.scala
+++ b/src/library/scala/collection/mutable/HashTable.scala
@@ -47,7 +47,7 @@ trait HashTable[A] extends AnyRef {
/** The actual hash table.
*/
- protected var table: Array[Entry] =
+ protected var table: Array[HashEntry[A, Entry]] =
if (initialSize == 0) null else new Array(initialSize)
/** The number of mappings contained in this hash table.
@@ -64,14 +64,14 @@ trait HashTable[A] extends AnyRef {
protected def findEntry(key: A): Entry = {
val h = index(elemHashCode(key))
- var e = table(h)
+ var e = table(h).asInstanceOf[Entry]
while (e != null && !elemEquals(e.key, key)) e = e.next
e
}
protected def addEntry(e: Entry) {
val h = index(elemHashCode(e.key))
- e.next = table(h)
+ e.next = table(h).asInstanceOf[Entry]
table(h) = e
tableSize = tableSize + 1
if (tableSize > threshold)
@@ -80,7 +80,7 @@ trait HashTable[A] extends AnyRef {
protected def removeEntry(key: A) : Option[Entry] = {
val h = index(elemHashCode(key))
- var e = table(h)
+ var e = table(h).asInstanceOf[Entry]
if (e != null) {
if (elemEquals(e.key, key)) {
table(h) = e.next
@@ -105,7 +105,7 @@ trait HashTable[A] extends AnyRef {
protected def entries: Iterator[Entry] = new Iterator[Entry] {
val iterTable = table
var idx = table.length - 1
- var es = iterTable(idx)
+ var es = iterTable(idx).asInstanceOf[Entry]
scan()
def hasNext = es != null
def next = {
@@ -117,7 +117,7 @@ trait HashTable[A] extends AnyRef {
def scan() {
while (es == null && idx > 0) {
idx = idx - 1
- es = iterTable(idx)
+ es = iterTable(idx).asInstanceOf[Entry]
}
}
}
@@ -140,7 +140,7 @@ trait HashTable[A] extends AnyRef {
while (e != null) {
val h = index(elemHashCode(e.key))
val e1 = e.next
- e.next = table(h)
+ e.next = table(h).asInstanceOf[Entry]
table(h) = e
e = e1
}