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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user