-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Special-case empty enumerables in AsyncEnumerable #112321
Merged
Merged
Conversation
This file contains 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
The goal here is to handle known empty inputs in a way that reduces unnecessary allocation, e.g. avoiding an iterator allocation or avoiding an intermediate collection. This does not modify operators where there isn't such overhead.
Tagging subscribers to this area: @dotnet/area-system-linq |
result : | ||
return | ||
source.IsEmpty() ? Empty<TResult>() : | ||
source as IAsyncEnumerable<TResult> ?? | ||
Impl(source, default); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe parenthesize?
This was referenced Feb 10, 2025
Open
src/libraries/System.Linq.AsyncEnumerable/src/System/Linq/Empty.cs
Outdated
Show resolved
Hide resolved
eiriktsarpalis
approved these changes
Feb 10, 2025
andrewjsaid
reviewed
Feb 10, 2025
src/libraries/System.Linq.AsyncEnumerable/src/System/Linq/Empty.cs
Outdated
Show resolved
Hide resolved
grendello
added a commit
to grendello/runtime
that referenced
this pull request
Feb 11, 2025
* main: Code clean up in AP for NonNull* (dotnet#112027) JIT: Invalidate LSRA's DFS tree if we aren't running new layout phase (dotnet#112364) Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250204.2 (dotnet#112339) Add doc on OS onboarding (dotnet#112026) Add `TypeName` APIs to simplify metadata lookup. (dotnet#111598) Internal monitor impl not using coop mutex causing deadlocks on Android. (dotnet#112358) Do not run NAOT arm64 OSX testing on all PRs (dotnet#112342) Special-case empty enumerables in AsyncEnumerable (dotnet#112321) Have mono handle ConvertToIntegerNative for Double and Single (dotnet#112206) Update dependencies from https://github.com/dotnet/arcade build 20250206.4 (dotnet#112338) System.Configuration.ConfigurationManager.Tests: use Assembly.Location to determine ThisApplicationPath. (dotnet#112231) Force write of local file header when "version needed to extract" changes (dotnet#112032) JIT: Don't reorder handler blocks (dotnet#112292) [RISC-V] Synthesize some floating constants inline (dotnet#111529) Enable `SA1000`: Spacing around keywords (dotnet#112302) Fix relocs for linux-riscv64 AOT (dotnet#112331)
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.
The goal here is to handle known empty inputs in a way that reduces unnecessary allocation, e.g. avoiding an iterator allocation or avoiding an intermediate collection. This does not modify operators where there isn't such overhead.