1
Fork 0

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.
This commit is contained in:
Alisdair Owens 2015-07-10 17:34:07 +01:00
parent e4e93196e1
commit 98f287240f
6 changed files with 166 additions and 0 deletions

View file

@ -906,6 +906,8 @@ mod tests {
use io::prelude::*;
use io;
use super::Cursor;
use test;
use super::repeat;
#[test]
fn read_until() {
@ -1024,4 +1026,13 @@ mod tests {
let mut buf = [0; 1];
assert_eq!(0, R.take(0).read(&mut buf).unwrap());
}
#[bench]
fn bench_read_to_end(b: &mut test::Bencher) {
b.iter(|| {
let mut lr = repeat(1).take(10000000);
let mut vec = Vec::with_capacity(1024);
super::read_to_end(&mut lr, &mut vec);
});
}
}