about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorRichard Janis Goldschmidt <janis.beckert@gmail.com>2016-09-11 16:48:04 +0200
committerRichard Janis Goldschmidt <janis.beckert@gmail.com>2016-09-11 16:48:04 +0200
commitc8b656bea5e90f1e174bee7e65cbd362914264b3 (patch)
treeeb000426ffe6e69eec92c1a8ea2cb17f5c04a19f /src/libstd
parent1fca1ab0e7be574022b2d229f0a6ad9bd580d1bf (diff)
downloadrust-c8b656bea5e90f1e174bee7e65cbd362914264b3.tar.gz
rust-c8b656bea5e90f1e174bee7e65cbd362914264b3.zip
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`.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/buffered.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs
index a26a932ad2d..dbb45d54f38 100644
--- a/src/libstd/io/buffered.rs
+++ b/src/libstd/io/buffered.rs
@@ -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<()> {