Rollup merge of #36397 - SuperFluffy:bufwriter_unnecessary_cmp, r=aturon

Remove unnecessary `cmp::min` from BufWriter::write

The first branch of the if statement already checks if `buf.len() >= self.buf.capacity()`, which makes the `cmp::min(buf.len(), self.buf.capacity())` redundant: the result will always be `buf.len()`. Therefore, we can pass the `buf` slice directly into `Write::write`.
This commit is contained in:
Guillaume Gomez 2016-09-13 10:25:49 +02:00 committed by GitHub
commit d6aa4e828c

View File

@ -468,8 +468,7 @@ impl<W: Write> Write for BufWriter<W> {
self.panicked = false;
r
} else {
let amt = cmp::min(buf.len(), self.buf.capacity());
Write::write(&mut self.buf, &buf[..amt])
Write::write(&mut self.buf, buf)
}
}
fn flush(&mut self) -> io::Result<()> {