Skip to content

Commit

Permalink
Use Vec::drain in BufWriter
Browse files Browse the repository at this point in the history
I happened past a comment that asked for functionality that we now have.
  • Loading branch information
bluss committed Jul 14, 2015
1 parent 1b28ffa commit 7b51c1c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/libstd/io/buffered.rs
Expand Up @@ -18,7 +18,6 @@ use cmp;
use error;
use fmt;
use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom};
use ptr;

/// The `BufReader` struct adds buffering to any reader.
///
Expand Down Expand Up @@ -308,14 +307,8 @@ impl<W: Write> BufWriter<W> {
}
}
if written > 0 {
// NB: would be better expressed as .remove(0..n) if it existed
unsafe {
ptr::copy(self.buf.as_ptr().offset(written as isize),
self.buf.as_mut_ptr(),
len - written);
}
self.buf.drain(..written);
}
self.buf.truncate(len - written);
ret
}

Expand Down
1 change: 1 addition & 0 deletions src/libstd/lib.rs
Expand Up @@ -119,6 +119,7 @@
#![feature(core_intrinsics)]
#![feature(core_prelude)]
#![feature(core_simd)]
#![feature(drain)]
#![feature(fnbox)]
#![feature(heap_api)]
#![feature(int_error_internals)]
Expand Down

0 comments on commit 7b51c1c

Please sign in to comment.