-
Notifications
You must be signed in to change notification settings - Fork 26
Make mark consistent with skip and IOBuffer
#201
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
Conversation
| ok &= isreadable(stream) | ||
| close(stream) | ||
| end | ||
| # read without stop_on_end should read the full data. |
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.
This test isn't related to this PR but was something I noticed wasn't covered by current tests.
| checkmode(stream) | ||
| return mark!(stream.buffer1) | ||
| function Base.mark(stream::TranscodingStream)::Int64 | ||
| ready_to_read!(stream) |
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.
This throws an error if mark is used on a stream in write, close, or panic modes.
| if mode === :read || mode === :stop | ||
| while !eof(stream) && buffersize(buffer1) < offset - skipped | ||
| n = buffersize(buffer1) | ||
| emptybuffer!(buffer1) |
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.
The use of emptybuffer! here was discarding potentially marked data.
| skipbuffer!(buffer1, offset - skipped) | ||
| end | ||
| else | ||
| # TODO: support skip in write mode |
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'm not sure what this TODO means, but I add a docstring to clarify that skip behaves like a read that ignores eof and discards the read bytes.
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 also moved the skip to be near the other read functions
mkitti
left a comment
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.
Looks good to me.
No description provided.