diff options
author | Paul Phillips <paulp@improving.org> | 2011-11-07 18:22:42 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-11-07 18:22:42 +0000 |
commit | a0a045f5c0b5aa6ed02c849c4ab013cfbfd4e24f (patch) | |
tree | e6a16b89ef2744e86222e53f34e83baf32a1d52d /src/library/scala/collection/immutable/Vector.scala | |
parent | 838a09f2a9e0c90df4c2d34832e758ae47ce26cd (diff) | |
download | scala-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/Vector.scala')
-rw-r--r-- | src/library/scala/collection/immutable/Vector.scala | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index 5c8046fa58..ab12300097 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -52,7 +52,8 @@ object Vector extends SeqFactory[Vector] { * @define willNotTerminateInf */ final class Vector[+A](private[collection] val startIndex: Int, private[collection] val endIndex: Int, focus: Int) -extends IndexedSeq[A] +extends AbstractSeq[A] + with IndexedSeq[A] with GenericTraversableTemplate[A, Vector] with IndexedSeqLike[A, Vector[A]] with VectorPointer[A @uncheckedVariance] @@ -90,7 +91,7 @@ override def companion: GenericCompanion[Vector] = Vector // can still be improved override /*SeqLike*/ - def reverseIterator: Iterator[A] = new Iterator[A] { + def reverseIterator: Iterator[A] = new AbstractIterator[A] { private var i = self.length def hasNext: Boolean = 0 < i def next(): A = @@ -636,7 +637,10 @@ override def companion: GenericCompanion[Vector] = Vector } -class VectorIterator[+A](_startIndex: Int, _endIndex: Int) extends Iterator[A] with VectorPointer[A @uncheckedVariance] { +class VectorIterator[+A](_startIndex: Int, _endIndex: Int) +extends AbstractIterator[A] + with Iterator[A] + with VectorPointer[A @uncheckedVariance] { private var blockIndex: Int = _startIndex & ~31 private var lo: Int = _startIndex & 31 |