summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/immutable/Set.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-11-07 18:22:42 +0000
committerPaul Phillips <paulp@improving.org>2011-11-07 18:22:42 +0000
commita0a045f5c0b5aa6ed02c849c4ab013cfbfd4e24f (patch)
treee6a16b89ef2744e86222e53f34e83baf32a1d52d /src/library/scala/collection/immutable/Set.scala
parent838a09f2a9e0c90df4c2d34832e758ae47ce26cd (diff)
downloadscala-a0a045f5c0b5aa6ed02c849c4ab013cfbfd4e24f.tar.gz
scala-a0a045f5c0b5aa6ed02c849c4ab013cfbfd4e24f.tar.bz2
scala-a0a045f5c0b5aa6ed02c849c4ab013cfbfd4e24f.zip
Dropped about 1.5 Mb off scala-library.jar.
This commit and the two subsequent commits were contributed by: Todd Vierling <tv@duh.org>. I combined some commits and mangled his commit messages, but all the credit is his. This pursues the same approach to classfile reduction seen in r19989 when AbstractFunctionN was introduced, but applies it to the collections. Thanks to -Xlint it's easy to verify that the private types don't escape. Design considerations as articulated by Todd: * Don't necessarily create concrete types for _everything_. Where a subtrait only provides a few additional methods, don't bother; instead, use the supertrait's concrete class and retain the "with". For example, "extends AbstractSeq[A] with LinearSeq[A]". * Examine all classes with .class file size greater than 10k. Named classes and class names ending in $$anon$<num> are candidates for analysis. * If a return type is currently inferred where an anon subclass would be returned, make the return type explicit. Don't allow the library-private abstract classes to leak into the public namespace [and scaladoc].
Diffstat (limited to 'src/library/scala/collection/immutable/Set.scala')
-rw-r--r--src/library/scala/collection/immutable/Set.scala10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/library/scala/collection/immutable/Set.scala b/src/library/scala/collection/immutable/Set.scala
index 89be64b1d2..fe3ce8fd0b 100644
--- a/src/library/scala/collection/immutable/Set.scala
+++ b/src/library/scala/collection/immutable/Set.scala
@@ -49,7 +49,7 @@ object Set extends ImmutableSetFactory[Set] {
private val hashSeed = "Set".hashCode
/** An optimized representation for immutable empty sets */
- private object EmptySet extends Set[Any] with Serializable {
+ private object EmptySet extends AbstractSet[Any] with Set[Any] with Serializable {
override def size: Int = 0
def contains(elem: Any): Boolean = false
def + (elem: Any): Set[Any] = new Set1(elem)
@@ -60,7 +60,7 @@ object Set extends ImmutableSetFactory[Set] {
/** An optimized representation for immutable sets of size 1 */
@SerialVersionUID(1233385750652442003L)
- class Set1[A] private[collection] (elem1: A) extends Set[A] with Serializable {
+ class Set1[A] private[collection] (elem1: A) extends AbstractSet[A] with Set[A] with Serializable {
override def size: Int = 1
def contains(elem: A): Boolean =
elem == elem1
@@ -79,7 +79,7 @@ object Set extends ImmutableSetFactory[Set] {
/** An optimized representation for immutable sets of size 2 */
@SerialVersionUID(-6443011234944830092L)
- class Set2[A] private[collection] (elem1: A, elem2: A) extends Set[A] with Serializable {
+ class Set2[A] private[collection] (elem1: A, elem2: A) extends AbstractSet[A] with Set[A] with Serializable {
override def size: Int = 2
def contains(elem: A): Boolean =
elem == elem1 || elem == elem2
@@ -99,7 +99,7 @@ object Set extends ImmutableSetFactory[Set] {
/** An optimized representation for immutable sets of size 3 */
@SerialVersionUID(-3590273538119220064L)
- class Set3[A] private[collection] (elem1: A, elem2: A, elem3: A) extends Set[A] with Serializable {
+ class Set3[A] private[collection] (elem1: A, elem2: A, elem3: A) extends AbstractSet[A] with Set[A] with Serializable {
override def size: Int = 3
def contains(elem: A): Boolean =
elem == elem1 || elem == elem2 || elem == elem3
@@ -120,7 +120,7 @@ object Set extends ImmutableSetFactory[Set] {
/** An optimized representation for immutable sets of size 4 */
@SerialVersionUID(-3622399588156184395L)
- class Set4[A] private[collection] (elem1: A, elem2: A, elem3: A, elem4: A) extends Set[A] with Serializable {
+ class Set4[A] private[collection] (elem1: A, elem2: A, elem3: A, elem4: A) extends AbstractSet[A] with Set[A] with Serializable {
override def size: Int = 4
def contains(elem: A): Boolean =
elem == elem1 || elem == elem2 || elem == elem3 || elem == elem4