-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Reduce memory usage by Array.Empty #3085
Reduce memory usage by Array.Empty #3085
Conversation
Note that this is a public API now returning a fixed array instead of a list, though an array seems more appropriate here. There is also |
The title totally got my expectations high, but the actual code change destroyed my expectations pretty fast. |
I was just looking up _items = s_emptyArray; In situations where an empty public ReadOnlyCollection<T> AsReadOnly()
=> new ReadOnlyCollection<T>(this); But straight-up swapping of an empty |
@ vatsan-madhavan Yeah, but we create a static field will cause unnecessary memory allocation, although there is only very little memory.
|
Makes sense. |
The Empty property are only used in TypeReferences