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`.
上级 1fca1ab0
......@@ -468,8 +468,7 @@ fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
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<()> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册