Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

natebosch
Copy link
Member

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

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
@natebosch
Copy link
Member Author

cc @scheglov - any concerns about landing this here? You might need to handle import conflicts when this version gets pulled in to the SDK.

@natebosch natebosch requested a review from lrhn January 12, 2024 04:28
@natebosch
Copy link
Member Author

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});
Copy link
Member

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.

@lrhn
Copy link
Member

lrhn commented Jan 12, 2024

If someone needs this, it's fine to release it in 2.X, and merge it into the 3.0 branch too.
Otherwise it's probably easier to just put it into the next major release.

I really should get back to releasing the 3.0 version.

@scheglov
Copy link
Contributor

cc @scheglov - any concerns about landing this here? You might need to handle import conflicts when this version gets pulled in to the SDK.

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 package:collection is pulled into SDK.

copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Jan 16, 2024
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>
@kevmoo
Copy link
Member

kevmoo commented Jun 7, 2024

@natebosch – care to proceed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants