Skip to content

Commit e0dfdc6

Browse files
committed
Added check for is_write_vectored
1 parent 1bf8ba3 commit e0dfdc6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/libstd/io/buffered.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,19 @@ impl<'a, W: Write> Write for LineWriterShim<'a, W> {
961961
/// write a partial line.
962962
/// - If the write only reports partial success, it does not attempt to
963963
/// find the precise location of the written bytes and buffer the rest.
964+
///
965+
/// If the underlying vector doesn't support vectored writing, we instead
966+
/// simply write the first non-empty buffer with `write`. This way, we
967+
/// get the benefits of more granular partial-line handling without losing
968+
/// anything in efficiency
964969
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
970+
if !self.is_write_vectored() {
971+
return match bufs.iter().find(|buf| !buf.is_empty()) {
972+
Some(buf) => self.write(buf),
973+
None => Ok(0),
974+
}
975+
}
976+
965977
// Find the buffer containing the last newline
966978
let last_newline_buf_idx = bufs
967979
.iter()

0 commit comments

Comments
 (0)