Skip to content

Minimze empty array allocations via centralized helper for pre-net46 #4041

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

Closed
stevenaw opened this issue Feb 28, 2022 · 3 comments · Fixed by #4042
Closed

Minimze empty array allocations via centralized helper for pre-net46 #4041

stevenaw opened this issue Feb 28, 2022 · 3 comments · Fixed by #4042
Assignees
Milestone

Comments

@stevenaw
Copy link
Member

stevenaw commented Feb 28, 2022

net462 + netstandard2 define a static Array.Empty<T>() helper which returns a cached empty array. There's a few places in the code where we #ifdef this in where it's easy but there's other places where this approach would be cumbersome. It might help to both cleanup the code + give a minor perf boost (via reduced allocations) by creating a helper to handle this.

This would be most useful for v3.13.x but could also have a place in v4 if we continue to target net45 there (#4036). If net45 support is dropped in v4, then we should instead update all callsites to just call Array.Empty<T> directly instead

@mikkelbu
Copy link
Member

mikkelbu commented Mar 6, 2022

@stevenaw It looks like #4042 didn't close this issue - even though it had a Fixes #4041 ??? - (also they are not linked by GH).

EDIT: I guess is it since we are not merging to master, but to a branch.

I've linked this PR now and will close this issue. Please reopen if you disagree.

@mikkelbu mikkelbu linked a pull request Mar 6, 2022 that will close this issue
@mikkelbu
Copy link
Member

mikkelbu commented Mar 6, 2022

Closed by #4042

@mikkelbu mikkelbu closed this as completed Mar 6, 2022
@stevenaw
Copy link
Member Author

stevenaw commented Mar 7, 2022

Hmm thanks for catching this @mikkelbu ! I wonder if the auto closing function only works for merging to main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants