collection icon indicating copy to clipboard operation
collection copied to clipboard

Add flattenedToList and flattenedToSet

Open natebosch opened this issue 2 years ago • 4 comments

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 https://github.com/dart-lang/sdk/commit/8d3b6ce54ccb09dd970cd45fc3cded4a35beac31

natebosch avatar Jan 12 '24 04:01 natebosch

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 avatar Jan 12 '24 04:01 natebosch

I'm not sure if we want to hold this on https://github.com/dart-lang/collection/pull/284 - we also have another new API on that branch waiting for publish.

natebosch avatar Jan 12 '24 04:01 natebosch

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.

lrhn avatar Jan 12 '24 16:01 lrhn

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.

scheglov avatar Jan 13 '24 21:01 scheglov

@natebosch – care to proceed?

kevmoo avatar Jun 07 '24 23:06 kevmoo