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

justinvp
Copy link
Contributor

Via a new internal IListProvider<TElement> interface similar to IArrayProvider<TElement> for ToArray().

public List<TResult> ToList()
{
var results = new List<TResult>(_source.Count);
for (int i = 0; i < _source.Count; i++)
Copy link
Member

Choose a reason for hiding this comment

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

Count here is an interface call. I'd suggest storing the result into a local and then using the local.

Via a new internal IListProvider<TElement> interface similar to
IArrayProvider<TElement> for ToArray().
@stephentoub
Copy link
Member

LGTM now. Thanks, Justin.

stephentoub added a commit that referenced this pull request Sep 24, 2015
Enumerable.ToList() Optimization
@stephentoub stephentoub merged commit f106622 into dotnet:master Sep 24, 2015
@justinvp justinvp deleted the linqtolist branch October 1, 2015 21:26
@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
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.

7 participants