diff options
author | Ruediger Klaehn <rklaehn@gmail.com> | 2012-08-20 22:43:54 +0200 |
---|---|---|
committer | Ruediger Klaehn <rklaehn@gmail.com> | 2012-08-20 22:43:54 +0200 |
commit | 470f93f9ad5f26795c737b5184d9db20358bd5f7 (patch) | |
tree | 55b826afe74d9e0742afddf454b1d048d722228f /src/library | |
parent | c51d0a8ad9aba128cd317ddbc13f1f49935066f0 (diff) | |
download | scala-470f93f9ad5f26795c737b5184d9db20358bd5f7.tar.gz scala-470f93f9ad5f26795c737b5184d9db20358bd5f7.tar.bz2 scala-470f93f9ad5f26795c737b5184d9db20358bd5f7.zip |
Prevent creation of a HashMapCollision1 with one element
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/immutable/HashMap.scala | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala index 0b297aeb45..72e58cb521 100644 --- a/src/library/scala/collection/immutable/HashMap.scala +++ b/src/library/scala/collection/immutable/HashMap.scala @@ -248,10 +248,13 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int { override def removed0(key: A, hash: Int, level: Int): HashMap[A, B] = if (hash == this.hash) { val kvs1 = kvs - key - if (!kvs1.isEmpty) - new HashMapCollision1(hash, kvs1) - else + if (kvs1.isEmpty) HashMap.empty[A,B] + else if(kvs1.tail.isEmpty) { + val kv = kvs1.head + new HashMap1[A,B](kv._1,hash,kv._2,kv) + } else + new HashMapCollision1(hash, kvs1) } else this override def iterator: Iterator[(A,B)] = kvs.iterator |