Skip to content

Commit c8b656b

Browse files
committed
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`.
1 parent 1fca1ab commit c8b656b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/libstd/io/buffered.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,7 @@ impl<W: Write> Write for BufWriter<W> {
468468
self.panicked = false;
469469
r
470470
} else {
471-
let amt = cmp::min(buf.len(), self.buf.capacity());
472-
Write::write(&mut self.buf, &buf[..amt])
471+
Write::write(&mut self.buf, buf)
473472
}
474473
}
475474
fn flush(&mut self) -> io::Result<()> {

0 commit comments

Comments
 (0)