From 1e4f765f30fc19947bb2c9f56c0eb47a30685caf Mon Sep 17 00:00:00 2001 From: Ruediger Klaehn Date: Mon, 20 Aug 2012 22:44:09 +0200 Subject: Prevent creation of a HashTrieMap with one child unless the child is a HashTrieMap itself --- src/library/scala/collection/immutable/HashMap.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 { -- cgit v1.2.3