Skip to content

Conversation

@eiriktsarpalis
Copy link
Member

@eiriktsarpalis eiriktsarpalis commented Feb 23, 2021

Makes the following changes to the new Enumerable.Take(Range) implementation:

  • Separate SizeOpt and SpeedOpt implementations for non-fromEnd ranges.
  • Optimize fromEnd ranges using Enumerable.TryGetNonEnumeratedCount to obtain the source count.
  • Change enumerator disposal semantics to more closely follow the TakeLast and SkipLast implementations.
  • Finally, expresses the TakeLast and SkipLast in terms of the Take(Range) implementation.

Fix #48631.

@ghost
Copy link

ghost commented Feb 23, 2021

Tagging subscribers to this area: @eiriktsarpalis
See info in area-owners.md if you want to be subscribed.

Issue Details

Makes the following changes to the new Enumerable.Take(Range) implementation:

  • Separate SizeOpt and SpeedOpt implementations for non-fromEnd ranges.
  • Optimize fromEnd ranges using Enumerable.TryGetNonEnumeratedCount to obtain the source count.
  • Change enumerator disposal semantics to more closely follow the TakeLast and SkipLast implementations.
  • Finally, expresses the TakeLast and SkipLast in terms of the Take(Range) implementation.
Author: eiriktsarpalis
Assignees: eiriktsarpalis
Labels:

area-System.Linq

Milestone: 6.0.0

@eiriktsarpalis
Copy link
Member Author

cc @Dixin

@eiriktsarpalis
Copy link
Member Author

I've been investigating the seemingly unrelated test failure affecting mono debug builds. The issue is caused by xunit's generic test parameter resolution logic: the removal of the private SkipLastIterator method seems to result in incorrect generic parameters being resolved for certain generic theory parameters.

I have pushed a commit to demonstrate this and to further show that the failures are not due to a regression introduced by this PR, but rather a bug of xunit running over mono debug builds.

@eiriktsarpalis eiriktsarpalis force-pushed the enumerable-take-optimizations branch from 7c73ea3 to 0c06999 Compare February 26, 2021 15:26
@eiriktsarpalis
Copy link
Member Author

Hi @stephentoub @layomia, this is ready for review, would you be able to take a look?

Base automatically changed from master to main March 1, 2021 09:08
@eiriktsarpalis eiriktsarpalis merged commit f7308f0 into dotnet:main Mar 1, 2021
@eiriktsarpalis eiriktsarpalis deleted the enumerable-take-optimizations branch March 1, 2021 13:56
@ghost ghost locked as resolved and limited conversation to collaborators Mar 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize the implementation of LINQ partitioning APIs

2 participants