From 8e51ee0bbd2979a15b361f4abfd95e1b2e4b2935 Mon Sep 17 00:00:00 2001 From: Justin Van Patten Date: Thu, 9 Jul 2015 10:27:24 -0700 Subject: [PATCH] Use Array.Empty for LINQ's Enumerable.Empty --- src/System.Linq/src/System/Linq/Enumerable.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/System.Linq/src/System/Linq/Enumerable.cs b/src/System.Linq/src/System/Linq/Enumerable.cs index d1655d77e329..f87958065845 100644 --- a/src/System.Linq/src/System/Linq/Enumerable.cs +++ b/src/System.Linq/src/System/Linq/Enumerable.cs @@ -1452,7 +1452,7 @@ private static IEnumerable RepeatIterator(TResult element, int public static IEnumerable Empty() { - return EmptyEnumerable.Instance; + return Array.Empty(); } public static bool Any(this IEnumerable source) @@ -2500,15 +2500,6 @@ public static decimal Average(this IEnumerable source, Func that allocates a new Enumerator each time. Unfortunately, we have to retain it - // for desktop platforms to avoid breaking scenarios that serialize an empty enumerable on 4.5 and deserialize it on 4.0. - // - internal class EmptyEnumerable - { - public static readonly TElement[] Instance = new TElement[0]; - } - internal class IdentityFunction { public static Func Instance @@ -2583,7 +2574,7 @@ public int Count { Grouping grouping = GetGrouping(key, false); if (grouping != null) return grouping; - return EmptyEnumerable.Instance; + return Array.Empty(); } }