Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

JonHanna
Copy link
Contributor

Optimised ToArray() and ToList() on the results of these methods.

cc: @stephentoub @VSadov

case 1:
_enumerator = _first.GetEnumerator();
if (_enumerator.MoveNext())
state = 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add braces here.

(In general, I don't like the style that's currently used through LINQ; it doesn't match what we've been trying to do in the rest of corefx. Cleaning that up if @VSadov agrees should be a separate effort at some point. In the meantime, though, in a case like this it just looks really strange to have an else with braces but the if without.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funnily enough while I do like brace-less two lines and hate the brace-less one-line used in this project, I've caught myself writing brace-less one-liners of late. This project is rubbing off on me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also like the corefx style more. Except for the avoidance of "var". :-)
We should run the formatter tool at some point on Linq and Expressions just for consistency.

Entered https://github.com/dotnet/corefx/issues/6150 for this.

@stephentoub
Copy link
Member

LGTM

@VSadov
Copy link
Member

VSadov commented Feb 16, 2016

LGTM
but would wait for the braces change

Optimised ToArray and ToList() on the results of these methods.
@JonHanna JonHanna force-pushed the distinct_union_toarray branch from 871bb0e to 6ab12bd Compare February 17, 2016 02:05
@JonHanna
Copy link
Contributor Author

Have fixed the braces.

A second commit here, not merged in yet so it can be dropped if you prefer, does a similar optimisation on chained unions to Stephen's for chained concatenations. While chained unions aren't as common, they aren't unheard of (the way to union 3+ sequences is to union and then union, after all) and this has the advantage of only having to create and fill a single hash set, rather than allocating and filling a new one for each call to Union().

@stephentoub
Copy link
Member

A second commit here

Mind creating a separate PR?

@JonHanna
Copy link
Contributor Author

Sure. Not being sure whether to include it in this or not is exactly why I didn't squash it in.

@JonHanna JonHanna force-pushed the distinct_union_toarray branch from 6ab12bd to 01d12cd Compare February 17, 2016 02:13
@JonHanna
Copy link
Contributor Author

There, that's as the original was, bar the braces.

@JonHanna
Copy link
Contributor Author

Test Innerloop Ubuntu Release Build and Test please

stephentoub added a commit that referenced this pull request Feb 17, 2016
Implement IIListProvider on Distinct() and Union().
@stephentoub stephentoub merged commit 3377742 into dotnet:master Feb 17, 2016
@JonHanna JonHanna deleted the distinct_union_toarray branch February 17, 2016 04:04
@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…array

Implement IIListProvider on Distinct() and Union().

Commit migrated from dotnet/corefx@3377742
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants