Description
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 Reader
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 why read_line
is slow when called on a TcpStream
.