Skip to content

Commit c869638

Browse files
committed
Added comment about BufWrite::write_all
1 parent 338a2c0 commit c869638

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/libstd/io/buffered.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,10 @@ impl<W: Write> Write for BufWriter<W> {
727727
}
728728

729729
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
730+
// Normally, `write_all` just calls `write` in a loop. We can do better
731+
// by calling `self.get_mut().write_all()` directly, which avoids
732+
// round trips through the buffer in the event of a series of partial
733+
// writes.
730734
if self.buf.len() + buf.len() > self.buf.capacity() {
731735
self.flush_buf()?;
732736
}

0 commit comments

Comments
 (0)