Remove a few array allocations from enumeration#118288
Merged
stephentoub merged 1 commit intodotnet:mainfrom Aug 3, 2025
Merged
Remove a few array allocations from enumeration#118288stephentoub merged 1 commit intodotnet:mainfrom
stephentoub merged 1 commit intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request optimizes memory allocation by replacing array allocations with ReadOnlySpan<T> for iteration scenarios, reducing garbage collection pressure in various .NET libraries.
Key Changes:
- Replace
new T[]array allocations withReadOnlySpan<T>collection expressions using[...]syntax - Optimize string splitting operations to use span-based methods instead of creating intermediate arrays
- Remove unnecessary braces in some code blocks
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| RegistryDataKey.cs | Replace registry key array with ReadOnlySpan for enumeration |
| CertificateHelpers.Windows.cs | Convert provider type arrays to ReadOnlySpan and clean up braces |
| TimeZoneInfo.Unix.Android.cs | Replace timezone file directory array with ReadOnlySpan |
| LinuxIPv4InterfaceProperties.cs | Convert file path array to ReadOnlySpan for iteration |
| ADStoreCtx_LoadStore.cs | Replace URN scheme array with ReadOnlySpan |
| Process.Linux.cs | Convert allowed programs array to ReadOnlySpan |
| EnumConverter.cs | Replace string.Split() with span-based splitting to avoid array allocation |
Comments suppressed due to low confidence (2)
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/CertificateHelpers.Windows.cs:122
- Extra opening brace. The using statement already provides the scope, so this additional brace is unnecessary.
{
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/CertificateHelpers.Windows.cs:155
- Extra opening brace. The using statement already provides the scope, so this additional brace is unnecessary.
{
EgorBo
reviewed
Aug 1, 2025
Contributor
|
Tagging subscribers to this area: @dotnet/area-meta |
MihaZupan
approved these changes
Aug 3, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
No description provided.