Use singleton for zero-element arrays.
Create an easily-inlinable method that accesses the array used by Enumerable.Empty (and hence not just shared within this project but likely with the client assembly or other libraries it uses) and use it anywhere a zero-element array is used, reducing allocations.
This commit is contained in:
@@ -90,7 +90,7 @@ namespace Newtonsoft.Json.Utilities
|
||||
#if !(PORTABLE40 || PORTABLE)
|
||||
EmptyTypes = Type.EmptyTypes;
|
||||
#else
|
||||
EmptyTypes = new Type[0];
|
||||
EmptyTypes = CollectionUtils.ArrayEmpty<Type>();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user