-
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
Interleave eagerly calls MoveNext #694
Comments
I don't think that's the case. It removes any iterator whose MoreLINQ/MoreLinq/Interleave.cs Lines 122 to 127 in 13c8c83
The loop that yields then uses the updated list of iterators and count. |
@atifaziz, as usual I was not clear enough in my first attempt to explain what is wrong here. The subject of this issue is not about the possible multiple calls to Considering this code. var resultSequence = sequenceA.Interleave(sequenceB); Expected behavior var resultSequence = sequenceA.Interleave(sequenceB);
var e = resultSequence.GetEnumerator();
e.MoveNext(); // call to MoveNext on the enumerator of sequenceA
e.MoveNext(); // call to MoveNext on the enumerator of sequenceB
e.MoveNext(); // call to MoveNext on the enumerator of sequenceA
... Current behavior One call to var resultSequence = sequenceA.Interleave(sequenceB);
var e = resultSequence.GetEnumerator();
e.MoveNext(); // call to MoveNext on the enumerator of sequenceA and sequenceB
e.MoveNext();
e.MoveNext(); // call to MoveNext on the enumerator of sequenceA and sequenceB
... Here the test I originally committed: MoreLINQ/MoreLinq.Test/InterleaveTest.cs Lines 38 to 53 in c9aa710
Here what is tested: |
Okay that makes more sense. I was focusing too much on the loop you quoted initially but you are right, it should avoid iterating other sequences unless needed. Thanks for the clarification. |
From this part of the code:
MoreLINQ/MoreLinq/Interleave.cs
Lines 135 to 139 in 13c8c83
We can see that interleave eagerly have called MoveNext on all the enumerators from all the input sequence before yielding the first value.
This is useless for the
ImbalancedInterleaveStrategy.Skip
strategy. And this strategy is the only one accessible from the user (the strategies enum is not public).The text was updated successfully, but these errors were encountered: