summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/immutable/HashMap.scala
diff options
context:
space:
mode:
authorRuediger Klaehn <rklaehn@gmail.com>2012-08-20 22:44:09 +0200
committerRuediger Klaehn <rklaehn@gmail.com>2012-08-20 22:44:09 +0200
commit1e4f765f30fc19947bb2c9f56c0eb47a30685caf (patch)
treeb9ef5380f95fec4b1894324fce192be7e1951941 /src/library/scala/collection/immutable/HashMap.scala
parent470f93f9ad5f26795c737b5184d9db20358bd5f7 (diff)
downloadscala-1e4f765f30fc19947bb2c9f56c0eb47a30685caf.tar.gz
scala-1e4f765f30fc19947bb2c9f56c0eb47a30685caf.tar.bz2
scala-1e4f765f30fc19947bb2c9f56c0eb47a30685caf.zip
Prevent creation of a HashTrieMap with one child unless the child is a HashTrieMap itself
Diffstat (limited to 'src/library/scala/collection/immutable/HashMap.scala')
-rw-r--r--src/library/scala/collection/immutable/HashMap.scala5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala
index 72e58cb521..acb3867cfa 100644
--- a/src/library/scala/collection/immutable/HashMap.scala
+++ b/src/library/scala/collection/immutable/HashMap.scala
@@ -350,7 +350,10 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
Array.copy(elems, 0, elemsNew, 0, offset)
Array.copy(elems, offset + 1, elemsNew, offset, elems.length - offset - 1)
val sizeNew = size - sub.size
- new HashTrieMap(bitmapNew, elemsNew, sizeNew)
+ if (elemsNew.length == 1 && !elemsNew(0).isInstanceOf[HashTrieMap[_,_]])
+ elemsNew(0)
+ else
+ new HashTrieMap(bitmapNew, elemsNew, sizeNew)
} else
HashMap.empty[A,B]
} else {