-
Notifications
You must be signed in to change notification settings - Fork 451
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
Traverse fixes #2365
Traverse fixes #2365
Conversation
In this case, you can use Edit: and actually looking at your implementation there's a tiny bit of a performance improvement that could be had with intializing the mutableList with the size of the Iterable/Nel so that it doesn't have to resize itself (this is also possible with |
I actually don't mind if anyone wants to do this, since the Also what is the opinion of everyone else regarding this: Should we make our return values extra safe against future type casts or not care?
This sounds nice, for the Iterable it is only possible if we first check that its a List, otherwise we can't efficiently know the size, but for Nel this should certainly be there. |
I'm not sure where you got this information from because looking at the implementation of
as you can see it just sets one single boolean flag called
Thankfully the arrow source code already has an extension on Iterable |
Welp I got to a different builder that just calls
I actually really like that we provide all these nice bits, but tbh I think the whole api is somewhat flawed if you have to^^ Either way, good! Thinking about this for a bit using
Edit: Actually nevermind, I'll wait for whatever the other maintainers think about this^^ |
I just saw this right now after making a PR, whoops 😅! Well yeah if the other maintainers are fine with using |
lgtm! |
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.
Thank you for taking care of this @1Jajen1! Looks great.
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.
thanks @1Jajen1 !
* FoldRight order * Test and fix traverse implementations * Undo foldRight changes Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
So traverse is broken in a few ways atm:
This pr fixes both of these issues without api changes and adds tests to verify that.
Also I changed the traverse implementations to accumulate in a mutable buffer. Using
List.plus
is a heavy perf hit since it quite literally copies the entire list (no sharing) and with ArrayList backed implementations that means a lot of array copies and thus gc strain. The mutable result is always casted to an immutable one implicitly so it should not leak to users (unless they manually cast again, but thats possible either way).