Fix a bug where calling NextIterator
on a "done" list iterator caused it to seemingly switch back to "not done" status
#4232
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This resolves #4226, reported by @james-d-mitchell. See the discussion there for further context.
Currently, iterators behave differently for immutable dense lists as opposed to other lists w.r.t. whether
NextIterator
throws an informative error when called on a finished iterator. Moreover, in one of the cases, callingNextIterator
on a finished iterator unnecessarily broke the value ofIsDoneIterator
.I tried making the error-checking behaviour consistent, but this led to an unacceptable 10% slowdown. Instead I've just removed the breaking of
IsDoneIterator
, and found one or two ways to speed up the code (mostly by reducing access to record components).If speed of iterators is important, then I think these changes are useful. If speed is not important, then perhaps I should reinstate proper error checking in
NextIterator_DenseList
...I've added some tests, removed some commented-out code, and rearranged a bit of code too - I'm happy to remove either of the latter two for being off-topic.
Quick experiments: