KEMBAR78
Remove a bunch of array allocations by stephentoub · Pull Request #82041 · dotnet/runtime · GitHub
Skip to content

Conversation

@stephentoub
Copy link
Member

A bunch of array allocations being removed by:

  • Changing static readonly arrays to be spans (taking advantage of RuntimeHelpers.CreateSpan)
  • Changing to use stackalloc
  • Changing interop to use pointers rather than arrays
  • Using ArrayPool
  • Computing a string at dev time rather than at run time
  • Lazy initializing the array when it's only needed on a fallback path
  • Deleting an array that's never used
  • Using Unsafe.AsRef to workaround Encoding not liking empty arrays

@ghost ghost assigned stephentoub Feb 13, 2023
@ghost ghost added the area-Meta label Feb 13, 2023
@ghost
Copy link

ghost commented Feb 13, 2023

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

Issue Details

A bunch of array allocations being removed by:

  • Changing static readonly arrays to be spans (taking advantage of RuntimeHelpers.CreateSpan)
  • Changing to use stackalloc
  • Changing interop to use pointers rather than arrays
  • Using ArrayPool
  • Computing a string at dev time rather than at run time
  • Lazy initializing the array when it's only needed on a fallback path
  • Deleting an array that's never used
  • Using Unsafe.AsRef to workaround Encoding not liking empty arrays
Author: stephentoub
Assignees: stephentoub
Labels:

area-Meta

Milestone: -

Copy link
Member

@tannergooding tannergooding left a comment

Choose a reason for hiding this comment

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

Changes generally LGTM. Just a couple comments/nits/suggestions

@stephentoub stephentoub merged commit 5584b26 into dotnet:main Feb 14, 2023
@stephentoub stephentoub deleted the removemorearrays branch February 14, 2023 17:31
@ghost ghost locked as resolved and limited conversation to collaborators Mar 16, 2023
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.

3 participants