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

Minimize + Centralize empty array declarations #4042

Merged
merged 4 commits into from
Mar 6, 2022

Conversation

stevenaw
Copy link
Member

Fixes #4041

This PR introduces a helper to cache empty array declarations. It will use Array.Empty<T> if possible, falling back to a custom implementation when that's not available.

This should be ported to v4 unless we decide to drop support for net45 there.

@stevenaw stevenaw changed the title Minimie + Centralize empty array declarations Minimize + Centralize empty array declarations Feb 28, 2022
Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

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

The idea and changes are good.
You forgot one in framework directory in DefaultSuiteBuilder.cs: IFixtureBuilder[] attrs = new IFixtureBuilder[0];
I assume you deliberately ignored zero array allocations in the testdata and tests directories.

@stevenaw
Copy link
Member Author

stevenaw commented Mar 1, 2022

Thanks @manfred-brands ! I've pushed an update to add the missed opportunity in DefaultSuiteBuilder
That's right, I had tried to focus just on distributable code since this was specific to v3.13 (and I thought it might be helpful to keep the branches as in-sync as possible) but I'm happy to include the test projects in this PR as well. Thoughts or preferences?

Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

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

I would not do more here and for main move to Array.Empty once we have a minimum target of net462

Copy link
Member

@mikkelbu mikkelbu left a comment

Choose a reason for hiding this comment

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

Only one comment, but I'm also happy to merge it as it is

@stevenaw stevenaw merged commit a19bc73 into nunit:v3.13-dev Mar 6, 2022
@stevenaw stevenaw deleted the centralize-array-empty branch March 6, 2022 19:05
@mikkelbu mikkelbu linked an issue Mar 6, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Minimze empty array allocations via centralized helper for pre-net46
3 participants