Skip to content
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

SI-9332 Iterator.span exhausts leading iterator #4530

Merged
merged 2 commits into from May 28, 2015

Conversation

som-snytt
Copy link
Contributor

Since the leading and trailing iterators returned by span
share the underlying iterator, the leading iterator must
flag when it is exhausted (when the span predicate fails)
since the trailing iterator will advance the underlying
iterator.

It would also be possible to leave the failing element in
the leading lookahead buffer, where it would forever fail
the predicate, but that entails evaluating the predicate
twice, on both enqueue and dequeue.

Since the leading and trailing iterators returned by span
share the underlying iterator, the leading iterator must
flag when it is exhausted (when the span predicate fails)
since the trailing iterator will advance the underlying
iterator.

It would also be possible to leave the failing element in
the leading lookahead buffer, where it would forever fail
the predicate, but that entails evaluating the predicate
twice, on both enqueue and dequeue.
@scala-jenkins scala-jenkins added this to the 2.11.7 milestone May 27, 2015
The queue is only used when the prefix is drained by finish.

Since a finished flag has been introduced, distinguish between
the drained state and using the underlying (buffered) iterator.
@lrytz
Copy link
Member

lrytz commented May 28, 2015

LGTM! What a selfish iterator :)

lrytz added a commit that referenced this pull request May 28, 2015
SI-9332 Iterator.span exhausts leading iterator
@lrytz lrytz merged commit 3ae3e9f into scala:2.11.x May 28, 2015
@som-snytt som-snytt deleted the issue/9332 branch May 28, 2015 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants