Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2013-03-25 17:16:35 +0400
committerMarek Safar <marek.safar@gmail.com>2013-03-25 17:16:35 +0400
commitf0af91e211cd0b5f7f45ce93e17e5ad12750ed25 (patch)
tree98f72511752feb308b80ebb503a1aaff954592e3 /mcs
parentb26a3411e562c16eb86fd0bf913d152f63cb1847 (diff)
Apply 9dc360146f373e64b2b8801a4284938759bc5229 to all where methods
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.Core/System.Linq/Enumerable.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/mcs/class/System.Core/System.Linq/Enumerable.cs b/mcs/class/System.Core/System.Linq/Enumerable.cs
index 035374cdaae..71f392690a4 100644
--- a/mcs/class/System.Core/System.Linq/Enumerable.cs
+++ b/mcs/class/System.Core/System.Linq/Enumerable.cs
@@ -3133,10 +3133,14 @@ namespace System.Linq
{
Check.SourceAndPredicate (source, predicate);
+ var array = source as TSource[];
+ if (array != null)
+ return CreateWhereIterator (array, predicate);
+
return CreateWhereIterator (source, predicate);
}
- static IEnumerable<TSource> CreateWhereIterator<TSource> (this IEnumerable<TSource> source, Func<TSource, int, bool> predicate)
+ static IEnumerable<TSource> CreateWhereIterator<TSource> (IEnumerable<TSource> source, Func<TSource, int, bool> predicate)
{
int counter = 0;
foreach (TSource element in source) {
@@ -3146,6 +3150,15 @@ namespace System.Linq
}
}
+ static IEnumerable<TSource> CreateWhereIterator<TSource> (TSource[] source, Func<TSource, int, bool> predicate)
+ {
+ for (int i = 0; i < source.Length; ++i) {
+ var element = source [i];
+ if (predicate (element, i))
+ yield return element;
+ }
+ }
+
#endregion
internal static ReadOnlyCollection<TSource> ToReadOnlyCollection<TSource> (this IEnumerable<TSource> source)