Skip to content

Avoid boxing LINQ on ImmutableArray<T> #18

@Flash0ver

Description

@Flash0ver

Not all System.Linq.Enumerable extension methods on IEnumerable<out T> have a more specific extension method overload for ImmutableArray<T>, which causes a boxing allocation.

E.g. Enumerable.GroupBy Method

Use a specific ImmutableArray<T> extension method overload to avoid boxing allocations.

This also (partially) applies to Roslyn struct-based collections, like Microsoft.CodeAnalysis.SyntaxTokenList and Microsoft.CodeAnalysis.SyntaxList<TNode>.

E.g.

foreach (AttributeSyntax attribute in node.AttributeLists.SelectMany(static attributeList => attributeList.Attributes))

Metadata

Metadata

Assignees

No one assigned

    Labels

    changelog:changedChange existing functionality (SemVer:MAJOR)scope:repoGitHub repository and/or Actionstype:perfA code change that improves performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions