about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorJamey Sharp <jamey@minilop.net>2016-05-27 19:34:20 -0700
committerJamey Sharp <jamey@minilop.net>2016-05-27 19:34:20 -0700
commit80d733385aa2ff150a5d6f83ecfe55afc7e19e68 (patch)
treef70d7f9165ec4ab083c6335dab56bb62abd23f48 /src/libstd
parent7bddce693cec4ae4eb6970ed91289815b316cff3 (diff)
downloadrust-80d733385aa2ff150a5d6f83ecfe55afc7e19e68.tar.gz
rust-80d733385aa2ff150a5d6f83ecfe55afc7e19e68.zip
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.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/cursor.rs2
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)?;