-
Notifications
You must be signed in to change notification settings - Fork 84
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
Add flattenedToList and flattenedToSet #328
base: master
Are you sure you want to change the base?
Conversation
For iterables which are known to be exhausted after flattening performance is better than the `sync*` implementation using a collection literal. Add `flattenedToList` as a performance improvement over `flattened.` Add `flattenedToSet` as new behavior for flattening to unique elements. Originally implemented in dart-lang/sdk@8d3b6ce
cc @scheglov - any concerns about landing this here? You might need to handle import conflicts when this version gets pulled in to the SDK. |
I'm not sure if we want to hold this on #284 - we also have another new API on that branch waiting for publish. |
empty, | ||
iterable([3, 4]) | ||
]).flattenedToSet, | ||
{1, 2, 3, 4}); |
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.
Also test that duplicates are removed.
If someone needs this, it's fine to release it in 2.X, and merge it into the 3.0 branch too. I really should get back to releasing the 3.0 version. |
https://dart-review.googlesource.com/c/sdk/+/346163 renames these methods in the analyzer, so there will be no conflict. I will migrate once this PR lands, and |
We might get it into package:collection dart-lang/collection#328 So, I rename it in the analyzer to prevent future conflict. Change-Id: I8cee41e76cb0f3c7147eda2b7284cec9f57aea92 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346163 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
@natebosch – care to proceed? |
For iterables which are known to be exhausted after flattening
performance is better than the
sync*
implementation using a collectionliteral.
Add
flattenedToList
as a performance improvement overflattened.
Add
flattenedToSet
as new behavior for flattening to unique elements.Originally implemented in
dart-lang/sdk@8d3b6ce