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

Replace some empty array allocations with Array.Empty #1466

Merged
merged 2 commits into from Apr 24, 2015

Conversation

Projects
None yet
7 participants
@stephentoub
Member

stephentoub commented Apr 22, 2015

Just a small cleanup...

We'd previously done a pass through the CoreFX libraries to replace most empty array allocations with "Array.Empty()". But in browsing through the code, I noticed a few more, either that we previously missed or that have crept in since.

This PR addresses those. There are still some remaining which I didn't replace, in particular ones that are returning new arrays from methods like ToArray, some of which are documented to return new arrays.

There were also some additional places I noticed that were doing their own caching of empty arrays, allocating a new array and storing it into a static. I've removed those fields and replaced the call sites with usage of Array.Empty, too.

@mellinoe

This comment has been minimized.

Show comment
Hide comment
@mellinoe

mellinoe Apr 23, 2015

Contributor

LGTM

Contributor

mellinoe commented Apr 23, 2015

LGTM

@hpshelton

This comment has been minimized.

Show comment
Hide comment
@hpshelton

hpshelton Apr 24, 2015

Contributor

👍

Are there tasks open to include FxCop in the build process and create custom rules for issues like this, usage of Console.WriteLine() in tests, and other things that keep creeping back in as new libraries are added?

Contributor

hpshelton commented Apr 24, 2015

👍

Are there tasks open to include FxCop in the build process and create custom rules for issues like this, usage of Console.WriteLine() in tests, and other things that keep creeping back in as new libraries are added?

@stephentoub

This comment has been minimized.

Show comment
Hide comment
@stephentoub

stephentoub Apr 24, 2015

Member

We plan to use Roslyn analyzers, but haven't done so yet as we don't yet require Roslyn for the build.

Member

stephentoub commented Apr 24, 2015

We plan to use Roslyn analyzers, but haven't done so yet as we don't yet require Roslyn for the build.

stephentoub added a commit that referenced this pull request Apr 24, 2015

Merge pull request #1466 from stephentoub/empty_arrays
Replace some empty array allocations with Array.Empty

@stephentoub stephentoub merged commit f667d7b into dotnet:master Apr 24, 2015

1 check passed

default Merged build finished.
Details

@stephentoub stephentoub deleted the stephentoub:empty_arrays branch Apr 24, 2015

@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016

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