Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
ba8c492
Baseline for ChainLinq
manofstick Dec 14, 2018
a1e3d6b
Added Aggregate Consumers
manofstick Dec 14, 2018
6ebc027
Added Any/All
manofstick Dec 14, 2018
23d49e4
Added Average
manofstick Dec 14, 2018
cb73b9d
Added Contains
manofstick Dec 14, 2018
26ae662
Added Distinct
manofstick Dec 14, 2018
699973c
Gutted all the existing Select performance improvements
manofstick Dec 14, 2018
123629f
Added SelectMany
manofstick Dec 16, 2018
f2e948e
Added Range
manofstick Dec 16, 2018
4c84541
Moved and cleaned SelectMany enumerators
manofstick Dec 16, 2018
0243653
Added Count
manofstick Dec 16, 2018
afbe8af
Fix project file
manofstick Dec 16, 2018
59e65d2
Added Array handling
manofstick Dec 16, 2018
cad3a4d
Added Concat
manofstick Dec 17, 2018
eb80027
Added Sum
manofstick Dec 17, 2018
85c0e9e
Consolidated enumerable consumption
manofstick Dec 18, 2018
056dd7f
minor refactoring
manofstick Dec 18, 2018
d4469bd
Append/Prepend built on top of Concat
manofstick Dec 19, 2018
bae05ed
Added Where
manofstick Dec 19, 2018
f35c7be
Added Take
manofstick Dec 19, 2018
df06b1f
Added Skip
manofstick Dec 19, 2018
0683e64
Removed tests where optimizations are not yet implemented
manofstick Dec 19, 2018
2bd9dd6
Added extra layer to class hierachery for internal identification
manofstick Dec 19, 2018
836d517
Optimization on Range for Skip/Take
manofstick Dec 20, 2018
283234f
Fixed Take for Range
manofstick Dec 20, 2018
84f19d9
Avoid Composite object when Identity link
manofstick Dec 20, 2018
7ad835a
Optimization of Merging Skip links
manofstick Dec 20, 2018
53f2238
Added Select merging
manofstick Dec 20, 2018
e9721db
Some Optimizations for Count
manofstick Dec 20, 2018
867e784
Optimized Count for SelectMany
manofstick Dec 20, 2018
2f69a7a
Added simple ToList
manofstick Dec 20, 2018
80fa7dc
Added ToArray
manofstick Dec 20, 2018
f01ba12
Added List
manofstick Dec 20, 2018
8042e0b
Added Min
manofstick Dec 20, 2018
353dc3b
Fixed List Consumable
manofstick Dec 20, 2018
88dc60b
Add Max
manofstick Dec 21, 2018
2aaca40
Removed all old code
manofstick Dec 21, 2018
d6e8148
Added Repeat
manofstick Dec 21, 2018
3dee44b
Added Where optimizations
manofstick Dec 21, 2018
c4f0b76
Added sealed to classes
manofstick Dec 21, 2018
e63cb0b
Removed old speed enhancments
manofstick Dec 21, 2018
eef98d2
Added Pipeline optimizations
manofstick Dec 21, 2018
aff8dc5
Put in the stubs for GetEnumerator optimizations
manofstick Dec 21, 2018
12af0b0
Moved optimized files into correct conditional
manofstick Dec 21, 2018
92e9acd
Merge remote-tracking branch 'Microsoft/master' into ChainLinqFence
manofstick Dec 22, 2018
b92b59f
Removed SizeOpt from project file
manofstick Dec 22, 2018
475f446
SelectMany handling for arrays and lists
manofstick Dec 22, 2018
cdb1119
Fix bug with GetCount on Concat
manofstick Dec 24, 2018
8761518
Additional bug fix for Concat GetCount
manofstick Jan 3, 2019
c56c431
Added an IList handler
manofstick Jan 4, 2019
9977cdd
Added optimizations for Skip/Take on Array & List
manofstick Jan 4, 2019
eb3c2ec
Added Last with some Skip/Take refactoring
manofstick Jan 4, 2019
324a2ff
Moved SpeedOpt files to correct part of project
manofstick Jan 4, 2019
b6a2d7d
Lookup creation via Consumer
manofstick Jan 5, 2019
7f182c4
Converted Lookup into Consumable
manofstick Jan 5, 2019
993ff02
Converted Grouped* types to Consumables
manofstick Jan 5, 2019
732634f
Added LookupResultsSelector
manofstick Jan 5, 2019
ec2ce0d
Restored Trim logic
manofstick Jan 5, 2019
9dba62d
Added Consumable Provider for Grouping
manofstick Jan 6, 2019
5720176
Added ToDictionary
manofstick Jan 7, 2019
73fd2e3
Fixed Lookup bug which enumerating
manofstick Jan 7, 2019
8a9d3ed
Fast paths for Select/Where on GetEnumerator
manofstick Jan 9, 2019
7fdf550
Avoid expensive IEnumerator<T> cast
manofstick Jan 11, 2019
cb6aafe
Changed ILink to an abstract class to allow enum based RTTI
manofstick Jan 12, 2019
10a837b
prefer if over switch for type check
manofstick Jan 12, 2019
ee05190
Added AddTail version that required no additional generic argument
manofstick Jan 12, 2019
fb28cf9
Moved Where optimization up to avoid expensive cast
manofstick Jan 12, 2019
0debf52
Removed use of IList
manofstick Jan 12, 2019
d32b970
Consistency in GetEnumerator optimization across containers
manofstick Jan 12, 2019
2172c0d
Added a Create to avoid Jit_VirtualFunctionalCall
manofstick Jan 12, 2019
ef0848b
Removed generic parameter on Compose
manofstick Jan 13, 2019
20b8bc3
Removed two argument Chain and many ChainEnd usages
manofstick Jan 13, 2019
82a145e
Removed another generic virtual method for perf
manofstick Jan 14, 2019
8691652
sealed some classes
manofstick Jan 14, 2019
158b2d4
Changed Consume signature to ensure a consumable
manofstick Jan 16, 2019
6201617
Remove some temporary consumables on Consume
manofstick Jan 17, 2019
63119c4
GroupBy handling for DefaultComparer
manofstick Jan 18, 2019
aa0f663
Missed Consumable check in Consume, so fixed.
manofstick Jan 19, 2019
a39da48
Added specialty Select Consumable for less garbage/performance
manofstick Jan 21, 2019
b382842
Added Where Specialization
manofstick Jan 21, 2019
193a82c
Moved Optimizations out to SpeedOpt files
manofstick Jan 22, 2019
505b265
Added SelectWhere Consumable
manofstick Jan 22, 2019
1e225a3
Added WhereSelect
manofstick Jan 24, 2019
5ed0ee7
Moved Select/Where construction into Utils
manofstick Jan 24, 2019
239ec00
Added TakeWhile
manofstick Jan 24, 2019
2c3ad03
Added TakeLast
manofstick Jan 24, 2019
07427d5
Added Delayed Consumable
manofstick Jan 28, 2019
abbc516
Fixed where SpeedOpt file was in project
manofstick Jan 28, 2019
9199068
Generalized the IPipelineXXX optimization interfaces
manofstick Feb 6, 2019
1ce670a
Added a Set using default comparer
manofstick Feb 8, 2019
0ef66a1
Added Except Link
manofstick Feb 8, 2019
222db93
Slight cleanup of Except
manofstick Feb 9, 2019
499f35e
Fix last checkin mistake
manofstick Feb 9, 2019
eb590a9
Rearranged code for better perf
manofstick Feb 11, 2019
f799fe0
Allow section of arrays to be enumerated
manofstick Feb 14, 2019
8a21094
Added a pooler for grouping
manofstick Feb 24, 2019
70687a1
Optimize the case where only a single value is stored in group
manofstick Feb 25, 2019
96ee05b
Merge remote-tracking branch 'Microsoft/master' into ChainLinqFence
manofstick Feb 26, 2019
75e098c
Fixes after merge
manofstick Feb 26, 2019
e1dfdee
More fixes from merge...
manofstick Feb 26, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ internal static bool TryGetCount<T>(IEnumerable<T> source, out int count)
return true;
}

if (source is IIListProvider<T> provider)
{
return (count = provider.GetCount(onlyIfCheap: true)) >= 0;
}

count = -1;
return false;
}
Expand Down
136 changes: 113 additions & 23 deletions src/System.Linq/src/System.Linq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,130 @@
<RootNamespace>System.Linq</RootNamespace>
<Configurations>netcoreapp-Debug;netcoreapp-Release;uap-Windows_NT-Debug;uap-Windows_NT-Release</Configurations>
</PropertyGroup>
<ItemGroup>
<Compile Include="System\Linq\ChainLinq\Consumables\Array.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Delayed.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Grouped.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\GroupingInternal.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\IList.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Lookup.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Where.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Select.cs" />
<Compile Include="System\Linq\ChainLinq\ConsumerEnumerators\Lookup.cs" />
<Compile Include="System\Linq\ChainLinq\ConsumerEnumerators\IList.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\Last.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\Lookup.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\TakeLast.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\ToDictionary.cs" />
<Compile Include="System\Linq\ChainLinq\Consume\Lookup.cs" />
<Compile Include="System\Linq\ChainLinq\Consume\IList.cs" />
<Compile Include="System\Linq\ChainLinq\GetEnumerator\IList.cs" />
<Compile Include="System\Linq\ChainLinq\GetEnumerator\Lookup.cs" />
<Compile Include="System\Linq\ChainLinq\Links\Except.cs" />
<Compile Include="System\Linq\ChainLinq\Links\LinkType.cs" />
<Compile Include="System\Linq\ChainLinq\Links\TakeWhile.cs" />
<Compile Include="System\Linq\ChainLinq\Links\TakeWhileIndexed.cs" />
<Compile Include="System\Linq\ChainLinq\Optimizations\Pipeline.cs" />
<Compile Include="System\Linq\Empty.cs" />
<Compile Include="System\Linq\ChainLinq\Chain.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\List.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Appender.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Repeat.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\ChainLinqConsumable.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Empty.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Base.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Concat.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Enumerable.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Prepender.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Range.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\SelectMany.cs" />
<Compile Include="System\Linq\ChainLinq\ConsumerEnumerators\List.cs" />
<Compile Include="System\Linq\ChainLinq\ConsumerEnumerators\Array.cs" />
<Compile Include="System\Linq\ChainLinq\ConsumerEnumerators\Concat.cs" />
<Compile Include="System\Linq\ChainLinq\ConsumerEnumerators\Repeat.cs" />
<Compile Include="System\Linq\ChainLinq\ConsumerEnumerators\Range.cs" />
<Compile Include="System\Linq\ChainLinq\ConsumerEnumerators\SelectMany.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\Aggregate.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\Max.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\Min.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\ToArray.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\ToList.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\Count.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\All.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\Any.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\Average.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\Contains.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\Reduce.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\Set.cs" />
<Compile Include="System\Linq\ChainLinq\Consumer\Sum.cs" />
<Compile Include="System\Linq\ChainLinq\Consume\List.cs" />
<Compile Include="System\Linq\ChainLinq\Consume\ReadOnlyMemory.cs" />
<Compile Include="System\Linq\ChainLinq\Consume\Concat.cs" />
<Compile Include="System\Linq\ChainLinq\Consume\Repeat.cs" />
<Compile Include="System\Linq\ChainLinq\Consume\UnknownEnumerable.cs" />
<Compile Include="System\Linq\ChainLinq\Consume\Range.cs" />
<Compile Include="System\Linq\ChainLinq\Consume\SelectMany.cs" />
<Compile Include="System\Linq\ChainLinq\Consume\Enumerable.cs" />
<Compile Include="System\Linq\ChainLinq\ConsumerEnumerators\Consumer.cs" />
<Compile Include="System\Linq\ChainLinq\ConsumerEnumerators\Enumerable.cs" />
<Compile Include="System\Linq\ChainLinq\GetEnumerator\List.cs" />
<Compile Include="System\Linq\ChainLinq\GetEnumerator\Array.cs" />
<Compile Include="System\Linq\ChainLinq\GetEnumerator\Concat.cs" />
<Compile Include="System\Linq\ChainLinq\GetEnumerator\Repeat.cs" />
<Compile Include="System\Linq\ChainLinq\GetEnumerator\Range.cs" />
<Compile Include="System\Linq\ChainLinq\GetEnumerator\SelectMany.cs" />
<Compile Include="System\Linq\ChainLinq\GetEnumerator\Enumerable.cs" />
<Compile Include="System\Linq\ChainLinq\Links\Compose.cs" />
<Compile Include="System\Linq\ChainLinq\Links\Distinct.cs" />
<Compile Include="System\Linq\ChainLinq\Links\Identity.cs" />
<Compile Include="System\Linq\ChainLinq\Links\Skip.cs" />
<Compile Include="System\Linq\ChainLinq\Links\Take.cs" />
<Compile Include="System\Linq\ChainLinq\Links\WhereIndexed.cs" />
<Compile Include="System\Linq\ChainLinq\Links\Where.cs" />
<Compile Include="System\Linq\ChainLinq\Links\Select.cs" />
<Compile Include="System\Linq\ChainLinq\Links\SelectIndexed.cs" />
<Compile Include="System\Linq\ChainLinq\Links\SelectMany.cs" />
<Compile Include="System\Linq\ChainLinq\Links\SelectManyIndexed.cs" />
<Compile Include="System\Linq\ChainLinq\Optimizations\Count.cs" />
<Compile Include="System\Linq\ChainLinq\Optimizations\Where.cs" />
<Compile Include="System\Linq\ChainLinq\Optimizations\Select.cs" />
<Compile Include="System\Linq\ChainLinq\Optimizations\SkipTake.cs" />
<Compile Include="System\Linq\ChainLinq\Utils.cs" />
</ItemGroup>
<ItemGroup>
<ContractProject Include="..\ref\System.Linq.csproj">
<TargetGroup>netcoreapp</TargetGroup>
</ContractProject>
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'"> <!-- Optimize for speed -->
<Compile Include="System\Linq\AppendPrepend.SpeedOpt.cs" />
<Compile Include="System\Linq\Concat.SpeedOpt.cs" />
<Compile Include="System\Linq\DefaultIfEmpty.SpeedOpt.cs" />
<Compile Include="System\Linq\Distinct.SpeedOpt.cs" />
<Compile Include="System\Linq\Enumerable.SpeedOpt.cs" />
<Compile Include="System\Linq\Grouping.SpeedOpt.cs" />
<Compile Include="System\Linq\Lookup.SpeedOpt.cs" />
<Compile Include="System\Linq\OrderedEnumerable.SpeedOpt.cs" />
<Compile Include="System\Linq\Partition.SpeedOpt.cs" />
<Compile Include="System\Linq\Range.SpeedOpt.cs" />
<Compile Include="System\Linq\Repeat.SpeedOpt.cs" />
<Compile Include="System\Linq\Reverse.SpeedOpt.cs" />
<Compile Include="System\Linq\Select.SpeedOpt.cs" />
<Compile Include="System\Linq\SelectMany.SpeedOpt.cs" />
<Compile Include="System\Linq\Skip.SpeedOpt.cs" />
<Compile Include="System\Linq\Take.SpeedOpt.cs" />
<Compile Include="System\Linq\Union.SpeedOpt.cs" />
<Compile Include="System\Linq\Where.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Appender.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Array.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Concat.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\IList.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\List.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Prepender.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Range.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Select.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\SelectMany.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\SelectWhere.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\Where.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Consumables\WhereSelect.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Links\Compose.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Links\Identity.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Links\Take.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Links\Select.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Links\SelectIndexed.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Links\Skip.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Links\SelectWhere.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Links\WhereSelect.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Links\Where.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Optimizations\Count.SpeedOpt.cs" />
<Compile Include="System\Linq\ChainLinq\Optimizations\SkipTake.SpeedOpt.cs" />
<Compile Include="$(CommonPath)\System\Collections\Generic\LargeArrayBuilder.SpeedOpt.cs">
<Link>System\Collections\Generic\LargeArrayBuilder.SpeedOpt.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'uap'"> <!-- Optimize for size -->
<Compile Include="System\Linq\Enumerable.SizeOpt.cs" />
<Compile Include="System\Linq\Skip.SizeOpt.cs" />
<Compile Include="System\Linq\Take.SizeOpt.cs" />
<Compile Include="$(CommonPath)\System\Collections\Generic\LargeArrayBuilder.SizeOpt.cs">
<Link>System\Collections\Generic\LargeArrayBuilder.SizeOpt.cs</Link>
</Compile>
Expand Down Expand Up @@ -77,8 +169,6 @@
<Compile Include="System\Linq\GroupJoin.cs" />
<Compile Include="System\Linq\Intersect.cs" />
<Compile Include="System\Linq\Iterator.cs" />
<Compile Include="System\Linq\IIListProvider.cs" />
<Compile Include="System\Linq\IPartition.cs" />
<Compile Include="System\Linq\Join.cs" />
<Compile Include="System\Linq\Last.cs" />
<Compile Include="System\Linq\Lookup.cs" />
Expand Down
32 changes: 3 additions & 29 deletions src/System.Linq/src/System/Linq/Aggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,7 @@ public static TSource Aggregate<TSource>(this IEnumerable<TSource> source, Func<
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.func);
}

using (IEnumerator<TSource> e = source.GetEnumerator())
{
if (!e.MoveNext())
{
ThrowHelper.ThrowNoElementsException();
}

TSource result = e.Current;
while (e.MoveNext())
{
result = func(result, e.Current);
}

return result;
}
return ChainLinq.Utils.Consume(source, new ChainLinq.Consumer.Reduce<TSource>(func));
}

public static TAccumulate Aggregate<TSource, TAccumulate>(this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func)
Expand All @@ -49,13 +35,7 @@ public static TAccumulate Aggregate<TSource, TAccumulate>(this IEnumerable<TSour
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.func);
}

TAccumulate result = seed;
foreach (TSource element in source)
{
result = func(result, element);
}

return result;
return ChainLinq.Utils.Consume(source, new ChainLinq.Consumer.Aggregate<TSource, TAccumulate, TAccumulate>(seed, func, x=>x));
}

public static TResult Aggregate<TSource, TAccumulate, TResult>(this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector)
Expand All @@ -75,13 +55,7 @@ public static TResult Aggregate<TSource, TAccumulate, TResult>(this IEnumerable<
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.resultSelector);
}

TAccumulate result = seed;
foreach (TSource element in source)
{
result = func(result, element);
}

return resultSelector(result);
return ChainLinq.Utils.Consume(source, new ChainLinq.Consumer.Aggregate<TSource, TAccumulate, TResult>(seed, func, resultSelector));
}
}
}
24 changes: 3 additions & 21 deletions src/System.Linq/src/System/Linq/AnyAll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ public static bool Any<TSource>(this IEnumerable<TSource> source)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.source);
}

using (IEnumerator<TSource> e = source.GetEnumerator())
{
return e.MoveNext();
}
return ChainLinq.Utils.Consume(source, new ChainLinq.Consumer.Any<TSource>(_ => true));
}

public static bool Any<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
Expand All @@ -33,15 +30,7 @@ public static bool Any<TSource>(this IEnumerable<TSource> source, Func<TSource,
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.predicate);
}

foreach (TSource element in source)
{
if (predicate(element))
{
return true;
}
}

return false;
return ChainLinq.Utils.Consume(source, new ChainLinq.Consumer.Any<TSource>(predicate));
}

public static bool All<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
Expand All @@ -56,15 +45,8 @@ public static bool All<TSource>(this IEnumerable<TSource> source, Func<TSource,
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.predicate);
}

foreach (TSource element in source)
{
if (!predicate(element))
{
return false;
}
}
return ChainLinq.Utils.Consume(source, new ChainLinq.Consumer.All<TSource>(predicate));

return true;
}
}
}
Loading