Skip to content

Enumerable Select skip iterator alloction when empty IList#128556

Closed
snakefoot wants to merge 1 commit into
dotnet:mainfrom
snakefoot:RemoveListSelectIterator
Closed

Enumerable Select skip iterator alloction when empty IList#128556
snakefoot wants to merge 1 commit into
dotnet:mainfrom
snakefoot:RemoveListSelectIterator

Conversation

@snakefoot
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 25, 2026 13:23
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label May 25, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Optimizes Enumerable.Select by adding an early-exit path for empty list-like sources and removing a redundant empty-array check.

Changes:

  • Adds an early return for IList<TSource> when Count == 0.
  • Removes the prior TSource[]-specific Length == 0 early return (now covered by the IList<TSource> branch).

Comment on lines 45 to +50
if (source is IList<TSource> ilist)
{
if (ilist.Count == 0)
{
return [];
}
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-linq
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Linq community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants