-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chunk improvements #3274
Chunk improvements #3274
Conversation
/** Views this Chunk as a Scala immutable Seq. | ||
* Contrary to all methods that start with _"to"_ (e.g. {{toVector}}, {{toArray}}), | ||
* this method does not copy data. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, not totally sure, that my Scaladoc formatting is wrong here.
…dexedSeq case (2.13)
if (c.isEmpty) this | ||
else | ||
c match { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (c.isEmpty) this | |
else | |
c match { | |
if (c.isEmpty) this | |
else if (this.isEmpty) c | |
else | |
c match { |
and the same recommendation for :+
down below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that ++
can simply call to this method (i.e. +:
) because they both seem doing the same thing, only the return type is different (++
returns Chunk
whereas +:
returns Queue
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@satorg I made the changes in a slightly different way, in order to minimize the amount of allocations.
For what it's worth the changes look good to me based on my limited knowledge, so take it with a grain of salt. 😉 The only thing missing from my point of view are unit tests, would be great to cover the newly introduced functionality:
|
@mpilquist @armanbilge I think the PR is ready for review, sorry for taking too long to add the tests. cc @satorg @filipwiech -- Thanks for the review comments :) |
Fixes #3271
Improvements
Chunk.asJava
.Chunk.asSeq
.Chunk
operations likecontains
&exists
(also overridden on theFoldable
instance).Chunk.javaList
to create chunks based on a Javaju.List
.Chunk.from
to accept any stdlib collection, and deprecate specific factories.Chunk.Queue
:+
,+:
, and++
methods.As always, I look forward to your feedback. Especially related to naming, scaladoc, and tests.