You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
These methods were originally implemented on
BufferedReader
because they require a call toread
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
andBufReader
have obvious fast implementations. One can imagine otherReader
implementations that are just proxies for an inner implementation and log data usage or whatever whereread_until
will be fast if it's fast on the underlyingReader
.I figure we can either add the methods to
Reader
with a warning saying "this will be really slow on certainReader
s" 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 whyread_line
is slow when called on aTcpStream
.cc @alexcrichton
The text was updated successfully, but these errors were encountered: