Skip to content

Remove PartialArray<T> in favor of Span<T> and avoid struct boxing#10009

Open
h3xds1nz wants to merge 3 commits intodotnet:mainfrom
h3xds1nz:partial-array-removal
Open

Remove PartialArray<T> in favor of Span<T> and avoid struct boxing#10009
h3xds1nz wants to merge 3 commits intodotnet:mainfrom
h3xds1nz:partial-array-removal

Conversation

@h3xds1nz
Copy link
Member

@h3xds1nz h3xds1nz commented Oct 28, 2024

Description

Removes the internal PartialArray<T> which is basically duplicating Span<T> functionality (in cases where it is used, not globally, obviously). Since this is then passed to IList<T> params and used as an interface, the struct needs to be boxed on top of everything and most of those calls are done via dispatch instead of using it directly.

Given how few places it is used, we can just replace it and remove the type altogether. In some places it was just used to wrap a regular array without any benefit.

The removed null-checks were really for null but I've checked the call chains and there's no way it should ever be null (or it wouldn't matter if the Span<T> was empty).

Customer Impact

Increased performance, decreased allocations.

Regression

No.

Testing

Local build.

Risk

Low.

Microsoft Reviewers: Open in CodeFlow

@h3xds1nz h3xds1nz requested review from a team as code owners October 28, 2024 16:24
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant