about summary refs log tree commit diff
path: root/src/libstd/io/stdio.rs
diff options
context:
space:
mode:
authorAlisdair Owens <awo101@zepler.net>2015-07-10 17:34:07 +0100
committerAlisdair Owens <awo101@zepler.net>2015-07-15 21:30:18 +0100
commit98f287240ff9518c1ea5519c5cd03dc2ba6d4452 (patch)
treeccf70108ba915d7280d99035f647a663ae0c1711 /src/libstd/io/stdio.rs
parente4e93196e16030ebf7a20c473849534235d676f8 (diff)
downloadrust-98f287240ff9518c1ea5519c5cd03dc2ba6d4452.tar.gz
rust-98f287240ff9518c1ea5519c5cd03dc2ba6d4452.zip
Add specializations of read_to_end for Stdin, TcpStream and File,
allowing them to read into a buffer containing uninitialized data,
rather than pay the cost of zeroing.
Diffstat (limited to 'src/libstd/io/stdio.rs')
-rw-r--r--src/libstd/io/stdio.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs
index 62bbb939a71..d8b7c8a282c 100644
--- a/src/libstd/io/stdio.rs
+++ b/src/libstd/io/stdio.rs
@@ -18,6 +18,7 @@ use io::lazy::Lazy;
 use io::{self, BufReader, LineWriter};
 use sync::{Arc, Mutex, MutexGuard};
 use sys::stdio;
+use sys_common::io::{read_to_end_uninitialized};
 use sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard};
 use libc;
 
@@ -277,6 +278,9 @@ impl<'a> Read for StdinLock<'a> {
     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
         self.inner.read(buf)
     }
+    fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
+        unsafe { read_to_end_uninitialized(self, buf) }
+    }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]