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:
Jon Hanna
2017-01-09 01:50:03 +00:00
parent 218c25c859
commit ff3bfaf51b
11 changed files with 69 additions and 39 deletions
@@ -176,7 +176,7 @@ namespace Newtonsoft.Json.Utilities
private delegate DynamicMetaObject Fallback(DynamicMetaObject errorSuggestion);
private static readonly Expression[] NoArgs = new Expression[0];
private static Expression[] NoArgs => CollectionUtils.ArrayEmpty<Expression>();
private static Expression[] GetArgs(params DynamicMetaObject[] args)
{