diff options
author | Aleksandar Prokopec <axel22@gmail.com> | 2012-05-04 13:47:05 +0200 |
---|---|---|
committer | Aleksandar Prokopec <axel22@gmail.com> | 2012-05-04 13:47:05 +0200 |
commit | b2c3f87c7b1b613495eb563d909f24e1e22369d1 (patch) | |
tree | 897c2dfa592cc353891af0a25762c68cc1cc49ab | |
parent | f146d5826fc335ee1ca9c285d69086a7475cb71e (diff) | |
download | scala-b2c3f87c7b1b613495eb563d909f24e1e22369d1.tar.gz scala-b2c3f87c7b1b613495eb563d909f24e1e22369d1.tar.bz2 scala-b2c3f87c7b1b613495eb563d909f24e1e22369d1.zip |
Fix for si-5590.
-rw-r--r-- | src/library/scala/collection/mutable/HashTable.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/LinkedHashMap.scala | 8 | ||||
-rw-r--r-- | test/files/run/t5590.check | 4 | ||||
-rw-r--r-- | test/files/run/t5590.scala | 31 |
4 files changed, 44 insertions, 1 deletions
diff --git a/src/library/scala/collection/mutable/HashTable.scala b/src/library/scala/collection/mutable/HashTable.scala index 06b7d40bfc..a2f78dbde9 100644 --- a/src/library/scala/collection/mutable/HashTable.scala +++ b/src/library/scala/collection/mutable/HashTable.scala @@ -187,7 +187,7 @@ trait HashTable[A, Entry >: Null <: HashEntry[A, Entry]] extends HashTable.HashU } /** Avoid iterator for a 2x faster traversal. */ - protected final def foreachEntry[C](f: Entry => C) { + protected def foreachEntry[C](f: Entry => C) { val iterTable = table var idx = lastPopulatedIndex var es = iterTable(idx) diff --git a/src/library/scala/collection/mutable/LinkedHashMap.scala b/src/library/scala/collection/mutable/LinkedHashMap.scala index cd174523b1..4150cf9eba 100644 --- a/src/library/scala/collection/mutable/LinkedHashMap.scala +++ b/src/library/scala/collection/mutable/LinkedHashMap.scala @@ -132,6 +132,14 @@ class LinkedHashMap[A, B] extends AbstractMap[A, B] } } + protected override def foreachEntry[C](f: Entry => C) { + var cur = firstEntry + while (cur ne null) { + f(cur) + cur = cur.later + } + } + override def clear() { clearTable() firstEntry = null diff --git a/test/files/run/t5590.check b/test/files/run/t5590.check new file mode 100644 index 0000000000..ad4a2eee64 --- /dev/null +++ b/test/files/run/t5590.check @@ -0,0 +1,4 @@ +Map(a -> a, b -> b, c -> c) +Map(a -> a, b -> b, c -> c) +Set(a, b, c, d, e) +Set(a, b, c, d, e)
\ No newline at end of file diff --git a/test/files/run/t5590.scala b/test/files/run/t5590.scala new file mode 100644 index 0000000000..9c806e0b7d --- /dev/null +++ b/test/files/run/t5590.scala @@ -0,0 +1,31 @@ + + + +import java.io._ +import collection._ + + + +object Test { + + def check(obj: AnyRef) { + println(obj) + + val bos = new ByteArrayOutputStream() + val out = new ObjectOutputStream(bos) + out.writeObject(obj) + val arr = bos.toByteArray() + val in = new ObjectInputStream(new ByteArrayInputStream(arr)) + val deser = in.readObject() + + println(deser) + } + + def main(args: Array[String]) { + val lhm = mutable.LinkedHashMap("a" -> "a", "b" -> "b", "c" -> "c") + val lhs = mutable.LinkedHashSet("a", "b", "c", "d", "e") + check(lhm) + check(lhs) + } + +} |