-
Notifications
You must be signed in to change notification settings - Fork 416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize Batch for empty IReadOnlyCollection<T> too #750
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have tests for this optimization, but I don't think there was one for IReadOnlyList previously.
CI failure looks unrelated
@@ -100,7 +100,7 @@ public static IEnumerable<IEnumerable<TSource>> Batch<TSource>(this IEnumerable< | |||
yield return resultSelector(bucket); | |||
} | |||
} | |||
case IReadOnlyList<TSource> list when list.Count == 0: | |||
case IReadOnlyCollection<TSource> collection when collection.Count == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add tests for this
Codecov Report
@@ Coverage Diff @@
## master #750 +/- ##
=======================================
Coverage 93.03% 93.03%
=======================================
Files 106 106
Lines 3473 3473
=======================================
Hits 3231 3231
Misses 242 242
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @fsateler's comment that a test should have been added.
but I don't think there was one for IReadOnlyList previously.
@fsateler There was one on line 123:
MoreLINQ/MoreLinq.Test/BatchTest.cs
Lines 121 to 129 in d567555
[TestCase(SourceKind.Sequence)] | |
[TestCase(SourceKind.BreakingList)] | |
[TestCase(SourceKind.BreakingReadOnlyList)] | |
[TestCase(SourceKind.BreakingCollection)] | |
public void BatchEmptySource(SourceKind kind) | |
{ | |
var batches = Enumerable.Empty<int>().ToSourceKind(kind).Batch(100); | |
Assert.That(batches, Is.Empty); | |
} |
Anyway, it was super quick to add another case so I went ahead and did it with e3cfba1.
@leandromoh Thanks for this PR!
@fsateler Thanks for your review.
thank you both! @atifaziz Merging is showing blocked for me. May you merge? |
No description provided.