Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Use Array.Empty in a few places - #1242

Merged
jkotas merged 5 commits into
dotnet:masterfrom
jamesqo:empty-array
May 6, 2016
Merged

jkotas merged 5 commits into
dotnet:masterfrom
jamesqo:empty-array

Conversation

@jamesqo

@jamesqo jamesqo commented May 5, 2016

Copy link
Copy Markdown
Contributor

This changes a couple of files throughout the repo to use Array.Empty<T> in place of new T[0], saving some unnecessary allocations.

Some of the classes affected:

  • List
  • Environment
  • Task
  • ConditionalWeakTable

cc @jkotas

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is always used as new Container().Resize() - that allocates a bunch of unnecessary garbage. It would be better to just allocate the arrays of the right size here to avoid all the garbage instead of patching over it with Array.Empty.

@jkotas

jkotas commented May 5, 2016

Copy link
Copy Markdown
Member

LGTM. Thanks!

@jkotas

jkotas commented May 5, 2016

Copy link
Copy Markdown
Member

Remove vscode file

You have several months old snapshot of the repo. The head has .gitignore for these files.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

_buckets.Length == 0 condition can be removed now.

@jkotas
jkotas merged commit 29428d2 into dotnet:master May 6, 2016
@jamesqo
jamesqo deleted the empty-array branch May 6, 2016 01:53
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