Skip to content

Commit 886ca78

Browse files
Replace ArraySegment with ReadOnlySpan in Batch/Window buffered operators (#639)
* Replace ArraySegment with ReadOnlySpan buffered op - Add a Func delegate for ReadOnlySpan. - Replace ArraySegment with ReadOnlySpan in Batch/Window buffered operators. - add breaking readonlyspan func --------- Co-authored-by: Stuart Turner <stuart@turner-isageek.com>
1 parent 1c63c16 commit 886ca78

22 files changed

+381
-348
lines changed

Source/SuperLinq.Async/PublicAPI/net6.0/PublicAPI.Unshipped.txt

Lines changed: 23 additions & 23 deletions
Large diffs are not rendered by default.

Source/SuperLinq.Async/PublicAPI/net7.0/PublicAPI.Unshipped.txt

Lines changed: 23 additions & 23 deletions
Large diffs are not rendered by default.

Source/SuperLinq.Async/PublicAPI/net8.0/PublicAPI.Unshipped.txt

Lines changed: 23 additions & 23 deletions
Large diffs are not rendered by default.

Source/SuperLinq.Async/PublicAPI/net9.0/PublicAPI.Unshipped.txt

Lines changed: 23 additions & 23 deletions
Large diffs are not rendered by default.

Source/SuperLinq.Async/PublicAPI/netcoreapp3.1/PublicAPI.Unshipped.txt

Lines changed: 23 additions & 23 deletions
Large diffs are not rendered by default.

Source/SuperLinq/Batch.Buffered.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static partial class SuperEnumerable
4545
public static IEnumerable<TResult> Batch<TSource, TResult>(
4646
this IEnumerable<TSource> source,
4747
int size,
48-
Func<ArraySegment<TSource>, TResult> resultSelector)
48+
ReadOnlySpanFunc<TSource, TResult> resultSelector)
4949
{
5050
ArgumentNullException.ThrowIfNull(source);
5151
ArgumentNullException.ThrowIfNull(resultSelector);
@@ -94,7 +94,7 @@ public static IEnumerable<TResult> Batch<TSource, TResult>(
9494
public static IEnumerable<TResult> Batch<TSource, TResult>(
9595
this IEnumerable<TSource> source,
9696
TSource[] array,
97-
Func<ArraySegment<TSource>, TResult> resultSelector)
97+
ReadOnlySpanFunc<TSource, TResult> resultSelector)
9898
{
9999
ArgumentNullException.ThrowIfNull(source);
100100
ArgumentNullException.ThrowIfNull(array);
@@ -149,7 +149,7 @@ public static IEnumerable<TResult> Batch<TSource, TResult>(
149149
this IEnumerable<TSource> source,
150150
TSource[] array,
151151
int size,
152-
Func<ArraySegment<TSource>, TResult> resultSelector)
152+
ReadOnlySpanFunc<TSource, TResult> resultSelector)
153153
{
154154
ArgumentNullException.ThrowIfNull(source);
155155
ArgumentNullException.ThrowIfNull(array);
@@ -164,7 +164,7 @@ private static IEnumerable<TResult> BatchImpl<TSource, TResult>(
164164
IEnumerable<TSource> source,
165165
TSource[] array,
166166
int size,
167-
Func<ArraySegment<TSource>, TResult> resultSelector)
167+
ReadOnlySpanFunc<TSource, TResult> resultSelector)
168168
{
169169
if (source is ICollection<TSource> coll)
170170
{
@@ -174,7 +174,7 @@ private static IEnumerable<TResult> BatchImpl<TSource, TResult>(
174174
if (coll.Count <= size)
175175
{
176176
coll.CopyTo(array, 0);
177-
yield return resultSelector(new ArraySegment<TSource>(array, 0, coll.Count));
177+
yield return resultSelector(new ReadOnlySpan<TSource>(array, 0, coll.Count));
178178
yield break;
179179
}
180180
}
@@ -185,12 +185,12 @@ private static IEnumerable<TResult> BatchImpl<TSource, TResult>(
185185
array[n++] = item;
186186
if (n == size)
187187
{
188-
yield return resultSelector(new ArraySegment<TSource>(array, 0, n));
188+
yield return resultSelector(new ReadOnlySpan<TSource>(array, 0, n));
189189
n = 0;
190190
}
191191
}
192192

193193
if (n != 0)
194-
yield return resultSelector(new ArraySegment<TSource>(array, 0, n));
194+
yield return resultSelector(new ReadOnlySpan<TSource>(array, 0, n));
195195
}
196196
}

Source/SuperLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt

Lines changed: 35 additions & 34 deletions
Large diffs are not rendered by default.

Source/SuperLinq/PublicAPI/net7.0/PublicAPI.Unshipped.txt

Lines changed: 35 additions & 34 deletions
Large diffs are not rendered by default.

Source/SuperLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt

Lines changed: 35 additions & 34 deletions
Large diffs are not rendered by default.

Source/SuperLinq/PublicAPI/net9.0/PublicAPI.Unshipped.txt

Lines changed: 35 additions & 34 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)