Skip to content

Conversation

stephentoub
Copy link
Member

When the incoming enumerable isn't a Task[] or List<Task>, we end up allocating either a Task[] or a List<T> (which then may incur one or more array allocations under the covers). We can avoid that by using an internal builder.

Closes #110530

When the incoming enumerable isn't a `Task[]` or `List<Task>`, we end up allocating either a `Task[]` or a `List<T>` (which then may incur one or more array allocations under the covers). We can avoid that by using a builder, either seeded with stack memory for
@stephentoub stephentoub requested a review from Copilot December 17, 2024 00:29
Copy link
Contributor

@Copilot 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.

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ValueListBuilder.cs:18

  • The use of the null-forgiving operator (!) on scratchBuffer is unnecessary and potentially misleading. The constructor should ensure that scratchBuffer is non-null before assignment.
_span = scratchBuffer!;

Tip: Leave feedback on Copilot's review comments with the 👎 and 👍 buttons to help improve review quality. Learn more

@stephentoub stephentoub merged commit 144dcae into dotnet:main Dec 17, 2024
137 of 139 checks passed
@stephentoub stephentoub deleted the whenallalloc branch December 17, 2024 00:32
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2025
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.

Possible Task.WhenAll performance improvements

3 participants