rollup merge of #21736: sfackler/bufread-capacity-fix

We don't care about how much space the allocation has, but the actual
usable space in the buffer.

r? @alexcrichton
This commit is contained in:
Alex Crichton 2015-01-30 12:03:24 -08:00
commit ebee4b4b37
1 changed files with 1 additions and 1 deletions

View File

@ -111,7 +111,7 @@ impl<R: Reader> Buffer for BufferedReader<R> {
impl<R: Reader> Reader for BufferedReader<R> {
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
if self.pos == self.cap && buf.len() >= self.buf.capacity() {
if self.pos == self.cap && buf.len() >= self.buf.len() {
return self.inner.read(buf);
}
let nread = {