summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/immutable/HashSet.scala
diff options
context:
space:
mode:
authorRuediger Klaehn <rklaehn@gmail.com>2012-08-09 03:43:23 +0200
committerRuediger Klaehn <rklaehn@gmail.com>2012-08-09 03:43:23 +0200
commit4c255c46fea189de16f10294f4e7176706f454f4 (patch)
treeb95e3415435cec96852212c3be771730ab1f5f99 /src/library/scala/collection/immutable/HashSet.scala
parent90714e7d4a03a33aa26f757217972e306b96c9d0 (diff)
downloadscala-4c255c46fea189de16f10294f4e7176706f454f4.tar.gz
scala-4c255c46fea189de16f10294f4e7176706f454f4.tar.bz2
scala-4c255c46fea189de16f10294f4e7176706f454f4.zip
Create a HashSet1 in case ks1 contains just one entry
Create HashSetCollision1 only if there is more than one element
Diffstat (limited to 'src/library/scala/collection/immutable/HashSet.scala')
-rw-r--r--src/library/scala/collection/immutable/HashSet.scala8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala
index c60fdc3bf1..7171e32ccc 100644
--- a/src/library/scala/collection/immutable/HashSet.scala
+++ b/src/library/scala/collection/immutable/HashSet.scala
@@ -151,10 +151,12 @@ object HashSet extends ImmutableSetFactory[HashSet] {
override def removed0(key: A, hash: Int, level: Int): HashSet[A] =
if (hash == this.hash) {
val ks1 = ks - key
- if (!ks1.isEmpty)
- new HashSetCollision1(hash, ks1)
- else
+ if(ks1.isEmpty)
HashSet.empty[A]
+ else if(ks1.tail.isEmpty)
+ new HashSet1(ks1.head, hash)
+ else
+ new HashSetCollision1(hash, ks1)
} else this
override def iterator: Iterator[A] = ks.iterator