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

Move BufferedReader::{read_until, read_line} somewhere else #10334

Closed
sfackler opened this issue Nov 7, 2013 · 0 comments
Closed

Move BufferedReader::{read_until, read_line} somewhere else #10334

sfackler opened this issue Nov 7, 2013 · 0 comments

Comments

@sfackler
Copy link
Member

sfackler commented Nov 7, 2013

These methods were originally implemented on BufferedReader because they require a call to read for each byte if they're implemented naively. However, BufferedReader isn't the only type for which this can be done efficiently. At the very least, MemReader and BufReader have obvious fast implementations. One can imagine other Reader implementations that are just proxies for an inner implementation and log data usage or whatever where read_until will be fast if it's fast on the underlying Reader.

I figure we can either add the methods to Reader with a warning saying "this will be really slow on certain Readers" or split these methods off onto a separate interface that's implemented by things that can do these efficiently. The second option puts a larger burden on library authors but will probably save people from wondering why read_line is slow when called on a TcpStream.

cc @alexcrichton

Jarcho pushed a commit to Jarcho/rust that referenced this issue Feb 26, 2023
…nishearth

book: move warning to the right place

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant