diff options
| author | Florian Hahn <flo@fhahn.com> | 2015-12-15 00:03:42 +0100 |
|---|---|---|
| committer | Florian Hahn <flo@fhahn.com> | 2015-12-18 13:32:14 +0100 |
| commit | de3e843d2467dff3ccb83efbae9260dc1b2a40bf (patch) | |
| tree | 296aa9288270388391d96df8386f3437cbf8ac02 /src/libstd/io/buffered.rs | |
| parent | ca52c56e346a2a2bb042bec441b5058df3e3e289 (diff) | |
| download | rust-de3e843d2467dff3ccb83efbae9260dc1b2a40bf.tar.gz rust-de3e843d2467dff3ccb83efbae9260dc1b2a40bf.zip | |
Use memchr in libstd where possible, closes #30076
Diffstat (limited to 'src/libstd/io/buffered.rs')
| -rw-r--r-- | src/libstd/io/buffered.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 90a79da3483..79eedbeda2c 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -18,6 +18,7 @@ use cmp; use error; use fmt; use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +use memchr; /// The `BufReader` struct adds buffering to any reader. /// @@ -746,7 +747,7 @@ impl<W: Write> LineWriter<W> { #[stable(feature = "rust1", since = "1.0.0")] impl<W: Write> Write for LineWriter<W> { fn write(&mut self, buf: &[u8]) -> io::Result<usize> { - match buf.iter().rposition(|b| *b == b'\n') { + match memchr::memrchr(b'\n', buf) { Some(i) => { let n = try!(self.inner.write(&buf[..i + 1])); if n != i + 1 { return Ok(n) } |
