From 8792a9c2c21da33c9a1af286d046581338a31001 Mon Sep 17 00:00:00 2001 From: Daniel Earwicker Date: Sat, 4 May 2024 14:58:52 +0100 Subject: [PATCH] Formatting --- Source/SuperLinq.Async/SortedMerge.cs | 48 ++++++--------------------- Source/SuperLinq/SortedMerge.cs | 48 ++++++--------------------- 2 files changed, 20 insertions(+), 76 deletions(-) diff --git a/Source/SuperLinq.Async/SortedMerge.cs b/Source/SuperLinq.Async/SortedMerge.cs index dc007e65..d209eaf7 100644 --- a/Source/SuperLinq.Async/SortedMerge.cs +++ b/Source/SuperLinq.Async/SortedMerge.cs @@ -296,14 +296,7 @@ static async IAsyncEnumerable Impl( foreach (var sequence in sequences) { var e = sequence.GetAsyncEnumerator(cancellationToken); - if (await e.MoveNextAsync()) - { - enumerators.Add(e); - } - else - { - await e.DisposeAsync(); - } + if (await e.MoveNextAsync()) enumerators.Add(e); else await e.DisposeAsync(); } #if NET6_0_OR_GREATER var queue = new PriorityQueue, TKey>( @@ -319,18 +312,11 @@ static async IAsyncEnumerable Impl( // Fast drain of final enumerator if (queue.Count == 0) { - while (await e.MoveNextAsync()) - { - yield return e.Current; - } - + while (await e.MoveNextAsync()) yield return e.Current; break; } - if (await e.MoveNextAsync()) - { - queue.Enqueue(e, keySelector(e.Current)); - } + if (await e.MoveNextAsync()) queue.Enqueue(e, keySelector(e.Current)); } #else @@ -353,18 +339,10 @@ static async IAsyncEnumerable Impl( } var index = Array.BinarySearch(arr, 1, count - 1, e, sourceComparer); - if (index < 0) - { - index = ~index; - } + if (index < 0) index = ~index; index--; - - if (index > 0) - { - Array.Copy(arr, 1, arr, 0, index); - } - + if (index > 0) Array.Copy(arr, 1, arr, 0, index); arr[index] = e; } @@ -373,31 +351,25 @@ static async IAsyncEnumerable Impl( var e = arr[0]; yield return e.Current; - while (await e.MoveNextAsync()) - { - yield return e.Current; - } + while (await e.MoveNextAsync()) yield return e.Current; } #endif } finally { - foreach (var e in enumerators) - { - await e.DisposeAsync(); - } + foreach (var e in enumerators) await e.DisposeAsync(); } } } #if !NET6_0_OR_GREATER internal sealed record class SourceComparer( - IComparer KeyComparer, - Func KeySelector + IComparer keyComparer, + Func keySelector ) : IComparer> { public int Compare(IAsyncEnumerator? x, IAsyncEnumerator? y) - => KeyComparer.Compare(KeySelector(x!.Current), KeySelector(y!.Current)); + => keyComparer.Compare(keySelector(x!.Current), keySelector(y!.Current)); } #endif } diff --git a/Source/SuperLinq/SortedMerge.cs b/Source/SuperLinq/SortedMerge.cs index c3628833..0ea5b3b5 100644 --- a/Source/SuperLinq/SortedMerge.cs +++ b/Source/SuperLinq/SortedMerge.cs @@ -370,14 +370,7 @@ static IEnumerable Impl(IEnumerable> sequences, Fu foreach (var sequence in sequences) { var e = sequence.GetEnumerator(); - if (e.MoveNext()) - { - enumerators.Add(e); - } - else - { - e.Dispose(); - } + if (e.MoveNext()) enumerators.Add(e); else e.Dispose(); } #if NET6_0_OR_GREATER @@ -394,18 +387,11 @@ static IEnumerable Impl(IEnumerable> sequences, Fu // Fast drain of final enumerator if (queue.Count == 0) { - while (e.MoveNext()) - { - yield return e.Current; - } - + while (e.MoveNext()) yield return e.Current; break; } - if (e.MoveNext()) - { - queue.Enqueue(e, keySelector(e.Current)); - } + if (e.MoveNext()) queue.Enqueue(e, keySelector(e.Current)); } #else @@ -428,18 +414,10 @@ static IEnumerable Impl(IEnumerable> sequences, Fu } var index = Array.BinarySearch(arr, 1, count - 1, e, sourceComparer); - if (index < 0) - { - index = ~index; - } + if (index < 0) index = ~index; index--; - - if (index > 0) - { - Array.Copy(arr, 1, arr, 0, index); - } - + if (index > 0) Array.Copy(arr, 1, arr, 0, index); arr[index] = e; } @@ -448,31 +426,25 @@ static IEnumerable Impl(IEnumerable> sequences, Fu var e = arr[0]; yield return e.Current; - while (e.MoveNext()) - { - yield return e.Current; - } + while (e.MoveNext()) yield return e.Current; } #endif } finally { - foreach (var e in enumerators) - { - e.Dispose(); - } + foreach (var e in enumerators) e.Dispose(); } } } #if !NET6_0_OR_GREATER internal sealed record class SourceComparer( - IComparer KeyComparer, - Func KeySelector + IComparer keyComparer, + Func keySelector ) : IComparer> { public int Compare(IEnumerator? x, IEnumerator? y) - => KeyComparer.Compare(KeySelector(x!.Current), KeySelector(y!.Current)); + => keyComparer.Compare(keySelector(x!.Current), keySelector(y!.Current)); } #endif }