diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2016-06-01 12:57:42 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2016-06-01 12:57:42 +0530 |
| commit | 0e65b75b3922e9b700ebaec055418086c07ef8a3 (patch) | |
| tree | 3a218cbdff92867c35a76796fd937a448b06da19 /src/libstd | |
| parent | d9cd460f6c90f821bf9b6e6a824a496660ce7281 (diff) | |
| parent | 80d733385aa2ff150a5d6f83ecfe55afc7e19e68 (diff) | |
| download | rust-0e65b75b3922e9b700ebaec055418086c07ef8a3.tar.gz rust-0e65b75b3922e9b700ebaec055418086c07ef8a3.zip | |
Rollup merge of #33921 - jameysharp:patch-1, r=alexcrichton
Inline simple Cursor write calls Implementing the Write trait for Cursors over slices is so light-weight that under some circumstances multiple writes can be fused into a single instruction. In general I think inlining these functions is a good idea because most of the code can be constant-folded and copy-propagated away. Closes issue #33916. r? @alexcrichton
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/cursor.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index a1002fdb645..2d780559db1 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -230,6 +230,7 @@ impl<T> BufRead for Cursor<T> where T: AsRef<[u8]> { #[stable(feature = "rust1", since = "1.0.0")] impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] fn write(&mut self, data: &[u8]) -> io::Result<usize> { let pos = cmp::min(self.pos, self.inner.len() as u64); let amt = (&mut self.inner[(pos as usize)..]).write(data)?; @@ -269,6 +270,7 @@ impl Write for Cursor<Vec<u8>> { #[stable(feature = "cursor_box_slice", since = "1.5.0")] impl Write for Cursor<Box<[u8]>> { + #[inline] fn write(&mut self, buf: &[u8]) -> io::Result<usize> { let pos = cmp::min(self.pos, self.inner.len() as u64); let amt = (&mut self.inner[(pos as usize)..]).write(buf)?; |
