std: Funnel read_to_end through to one location
This pushes the implementation detail of proxying `read_to_end` through to `read_to_end_uninitialized` all the way down to the `FileDesc` and `Handle` implementations on Unix/Windows. This way intermediate layers will also be able to take advantage of this optimized implementation. This commit also adds the optimized implementation for `ChildStdout` and `ChildStderr`.
This commit is contained in:
parent
eabfc160f8
commit
d46c99abe8
15 changed files with 136 additions and 11 deletions
|
@ -22,7 +22,6 @@ use ffi::OsString;
|
|||
use io::{self, SeekFrom, Seek, Read, Write};
|
||||
use path::{Path, PathBuf};
|
||||
use sys::fs as fs_imp;
|
||||
use sys_common::io::read_to_end_uninitialized;
|
||||
use sys_common::{AsInnerMut, FromInner, AsInner, IntoInner};
|
||||
use vec::Vec;
|
||||
use time::SystemTime;
|
||||
|
@ -351,7 +350,7 @@ impl Read for File {
|
|||
self.inner.read(buf)
|
||||
}
|
||||
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
|
||||
unsafe { read_to_end_uninitialized(self, buf) }
|
||||
self.inner.read_to_end(buf)
|
||||
}
|
||||
}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -372,6 +371,9 @@ impl<'a> Read for &'a File {
|
|||
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> {
|
||||
self.inner.read_to_end(buf)
|
||||
}
|
||||
}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a> Write for &'a File {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue