diff options
author | Rex Kerr <ichoran@gmail.com> | 2016-01-14 15:14:53 -0800 |
---|---|---|
committer | Rex Kerr <ichoran@gmail.com> | 2016-01-30 18:32:27 -0800 |
commit | 6eaae1b969b68ed3dc65a40613a8168b09246256 (patch) | |
tree | 35118267c53111a2f9ce7e2a0ddde0ff903fa2eb /src/library/scala/collection/immutable/Vector.scala | |
parent | 78f0437ac06e71a94a38721751ef5d36ca62c062 (diff) | |
download | scala-6eaae1b969b68ed3dc65a40613a8168b09246256.tar.gz scala-6eaae1b969b68ed3dc65a40613a8168b09246256.tar.bz2 scala-6eaae1b969b68ed3dc65a40613a8168b09246256.zip |
Clarified and expanded which Builders were reusable
This additionally fixes both SI-8648 and SI-9564.
Added documentation to Builder to clarify that in general Builders are NOT reusable.
Altered implementation of GrowingBuilder to use Growable instance's clear (not valid for a reusable builder, but this one isn't reusable).
Added a new marker trait ReusableBuilder that specifies that these builders should be reusable. This trait overrides the clear and result methods while leaving them abstract in order to supply appropriate scaladoc.
Made all Array builders Reusable in all cases (by setting capacity to 0 if the original array is returned). (Fixed a poor implmentation of Array[Unit] builder along the way.)
Documented which other builders were already reusable (maps, sets, Vector, LazyBuilder, StringBuilder, ListBuffer, etc.).
Diffstat (limited to 'src/library/scala/collection/immutable/Vector.scala')
-rw-r--r-- | src/library/scala/collection/immutable/Vector.scala | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index cd2d3f843b..754196e6c1 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -13,7 +13,7 @@ package immutable import scala.annotation.unchecked.uncheckedVariance import scala.compat.Platform import scala.collection.generic._ -import scala.collection.mutable.Builder +import scala.collection.mutable.{Builder, ReusableBuilder} import scala.collection.parallel.immutable.ParVector /** Companion object to the Vector class @@ -704,8 +704,8 @@ extends AbstractIterator[A] } } - -final class VectorBuilder[A]() extends Builder[A,Vector[A]] with VectorPointer[A @uncheckedVariance] { +/** A class to build instances of `Vector`. This builder is reusable. */ +final class VectorBuilder[A]() extends ReusableBuilder[A,Vector[A]] with VectorPointer[A @uncheckedVariance] { // possible alternative: start with display0 = null, blockIndex = -32, lo = 32 // to avoid allocating initial array if the result will be empty anyways |