Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

h3xds1nz
Copy link
Contributor

@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