|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Seq.apply: s/List/ArrayBuffer/Hi.
Seq.apply currently returns List, as written in collection/immutable/Sequence.scala. I think Seq.apply("a", "b", "z") should return ArrayBuffer, that I've described in 5 min ago letter. Because ArrayBuffer is significantly faster and consumes fewer memory then List. I see only two cases when List is better then ArrayBuffer: — List frees head, after you call drop, ArrayBuffer always holds underlying Array. That is not a big problem (although it should be mentioned in the scaladoc) — List has fast prepend element operation. This not important, because Seq has no prepend method. So, Scala developers, please, change SequenceFactory.newBuilder method to: def newBuilder[A, Builder[A, Sequence]] = VectorFactory.newBuilder S. |
|
|
Re: Seq.apply: s/List/ArrayBuffer/On Wed, Sep 23, 2009 at 3:13 AM, Stepan Koltsov <yozh@...> wrote:
> Hi. > > Seq.apply currently returns List, as written in > collection/immutable/Sequence.scala. > > I think Seq.apply("a", "b", "z") should return ArrayBuffer, that I've > described in 5 min ago letter. > > Because ArrayBuffer is significantly faster and consumes fewer memory then List. > > I see only two cases when List is better then ArrayBuffer: > > — List frees head, after you call drop, ArrayBuffer always holds > underlying Array. That is not a big problem (although it should be > mentioned in the scaladoc) > — List has fast prepend element operation. This not important, because > Seq has no prepend method. > > So, Scala developers, please, change SequenceFactory.newBuilder method to: > > def newBuilder[A, Builder[A, Sequence]] = VectorFactory.newBuilder > > S. > implementations. Your proposal would break that consistency. Cheers -- Martin |
|
|
Re: Seq.apply: s/List/ArrayBuffer/I have no particular opinion one way or the other, but perhaps it could return an immutable.Vector.
--j On Wed, Sep 23, 2009 at 12:24 AM, martin odersky <martin.odersky@...> wrote:
|
|
|
Re: Seq.apply: s/List/ArrayBuffer/Oops. Missed the thread right after this that suggested just that.
Sorry :) On Wed, Sep 23, 2009 at 12:08 PM, Jorge Ortiz <jorge.ortiz@...> wrote: I have no particular opinion one way or the other, but perhaps it could return an immutable.Vector. |
| Free embeddable forum powered by Nabble | Forum Help |