Repository navigation
Add optimisation for IReadOnlyCollection<TSource> - #135262
Draft
MikeBarker-MSFT wants to merge 1 commit into
Draft
MikeBarker-MSFT wants to merge 1 commit into
MikeBarker-MSFT wants to merge 1 commit into
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-linq |
MikeBarker-MSFT
marked this pull request as draft
October 6, 2026 08:46
Member
|
It's still under discussion for whether we should do the optimization like this. See #42254. |
MikeBarker-MSFT
marked this pull request as ready for review
October 6, 2026 09:11
Author
Thank you @huoyaoyuan , I had searched for such an issue, but has missed this one. |
MikeBarker-MSFT
marked this pull request as draft
October 6, 2026 11:31
This was referenced Oct 6, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add optimisation for
IReadOnlyCollection<TSource>when using the.Countproperty.The optimisations in LINQ take consideration of
ICollection<T>,Iterator<T>andICollection; these optimisations can be expanded for theIReadOnlyCollection<T>case too. This occurs inCount,TryGetNonEnumeratedCount,Any, and various helper methods.I have also added a test case for the optimisation route for
TryGetNonEnumeratedCount. Other routes do not have specific tests.(FYI: A further code clean-up could collapse these occurrences to all utilise
TryGetNonEnumeratedCountand reduce code duplication. This is not done in this PR.)Fix #135266