diff options
author | Ruediger Klaehn <rklaehn@gmail.com> | 2012-08-20 23:52:37 +0200 |
---|---|---|
committer | Ruediger Klaehn <rklaehn@gmail.com> | 2012-08-20 23:52:37 +0200 |
commit | 93f5013e7f893a2cb40df67f3cf69762846d1919 (patch) | |
tree | 7c1d87588c4bc8e93fa0221e3db20d0ea162ed20 /src | |
parent | acc54bf816617b52fbbb412ac33a65f0e99f468b (diff) | |
download | scala-93f5013e7f893a2cb40df67f3cf69762846d1919.tar.gz scala-93f5013e7f893a2cb40df67f3cf69762846d1919.tar.bz2 scala-93f5013e7f893a2cb40df67f3cf69762846d1919.zip |
Check if subNew is the only child and if it is a leaf.
If this is the case we must return subNew because a HashTrieMap with one leaf element is not allowed by the assertions
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/collection/immutable/HashMap.scala | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala index 1508185336..cdb2b71884 100644 --- a/src/library/scala/collection/immutable/HashMap.scala +++ b/src/library/scala/collection/immutable/HashMap.scala @@ -359,6 +359,8 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int { new HashTrieMap(bitmapNew, elemsNew, sizeNew) } else HashMap.empty[A,B] + } else if(elems.length == 1 && !subNew.isInstanceOf[HashTrieMap[_,_]]) { + subNew } else { val elemsNew = new Array[HashMap[A,B]](elems.length) Array.copy(elems, 0, elemsNew, 0, elems.length) |