Skip to content

Conversation

@stephentoub
Copy link
Member

This also makes Enumerable.ToArray more inlineable and removes a bit of duplicated code.

This also makes Enumerable.ToArray more inlineable and removes a bit of duplicated code.
@dotnet-policy-service
Copy link
Contributor

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

[MethodImpl(MethodImplOptions.NoInlining)] // avoid large stack allocation impacting other paths
static TSource[] EnumerableToArray(IEnumerable<TSource> source)
{
if (source is null)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: nesting validation inside the local method will result in its compiler-generated name to show up in the stack trace. I would prefer it if validation was done separately on each public method even if that results in duplication.

@stephentoub stephentoub merged commit 785d62b into dotnet:main Mar 25, 2024
@stephentoub stephentoub deleted the distincttoarray branch March 25, 2024 16:22
@github-actions github-actions bot locked and limited conversation to collaborators Apr 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

2 participants