Add Stream.isAtEnd() (AI) - #2007
Conversation
|
Thank you! Please document and give an example of the error case of an element not in stream. Thanks for making the docs concise. Please have agent check whether this is any place in the codebase where we should have used this (possibly not any cases but just have it check ) |
|
Error case is in the docstring now (SitesException when the element is not in the Stream). No call sites to switch. The |
|
The use case I had in mind was to replace iterations over _elements, not _endElements. See the main loop in quantize(). You could iterate elements, and continue if isAtEnd. |
quantize() iterated the private _elements to avoid touching elements stored at the end. Iterate the public .elements instead and skip them with the new isAtEnd(), which is the use case the method was added for. This is not only cosmetic: elementOffset() returns a concrete offset for an at-end element, so quantizing one would overwrite its AT_END marker while leaving it in _endElements. The added test fails without the skip.
|
good call, that one works. quantize() now iterates .elements and continues on isAtEnd instead of reaching into _elements. it turned out not to be cosmetic: elementOffset returns a real offset for an at-end element, so quantizing one clears its AT_END marker while it stays in _endElements. added a test that fails without the skip. |
I barely remember that |
Fixes #1069
Adds
Stream.isAtEnd(element)next tostoreAtEnd(), using the formagreed on the issue:
If the element is not in the Stream,
SitesExceptionfromelementOffsetis left uncaught.
quantize()already iteratesuseStream._elements, so end elements arealready skipped. Other
_endElementsuses are Stream internals, freeze/thaw,tree construction, or the
getOffsetBySitefallback afterelementOffsethas already failed. None of those were a safe one-line swap to
isAtEnd().Tests:
7 passed.
both passed.
This PR is entirely AI written.
AI/LLM disclosure