-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
provide a peeking API to std.io.BufferedReader #4501
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
Comments
Hello, Since I make use of io.PeekStream and it just got removed, I would like to contribute to this issue.
Would this be acceptable? |
that seems backwards. there should be a |
I agree that it would be nice to have a But previously |
I have a question, how do we handle the data after Edit: I didn't notice that the putBack maybe the solution of my question, sorry |
The point of BufferedInStream is to call
read()
on the underlying stream in bursts, rather than separate calls. E.g. to make 1 syscall toread()
reading 999 bytes, rather than 999 syscalls toread()
reading 1 byte each.The point of PeekStream is to be able to "put back" bytes, so that the next call to
read()
will get them again. In order to accomplish this, PeekStream needs a buffer. That makes PeekStream also a BufferedInStream.All we need to unify these two APIs is for BufferedInStream to have a parameter called
reserved_buffer_space
or something like this, and then it's guaranteed to be able to "put back" this many elements.Related:
The text was updated successfully, but these errors were encountered: