Просмотр исходного кода

[PLinq] Fix and improve Skip operator and use two different versions of the predicate depending on the relative order of the query.

This actually make the operator complies to the behavior described in MSDN "Order Preservation" table.
Jérémie Laval 15 лет назад
Родитель
Сommit
7704dbed38
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      mcs/class/System.Core/System.Linq/ParallelEnumerable.cs

+ 4 - 1
mcs/class/System.Core/System.Linq/ParallelEnumerable.cs

@@ -942,7 +942,10 @@ namespace System.Linq
 			if (source == null)
 				throw new ArgumentNullException ("source");
 
-			return source.Where ((e, i) => i >= count);
+			return source.Node.IsOrdered () ?
+				source.Where ((e, i) => i >= count) :
+				source.Where ((e) => count < 0 || Interlocked.Decrement (ref count) < 0);
+
 		}
 
 		public static ParallelQuery<TSource> SkipWhile<TSource> (this ParallelQuery<TSource> source,