1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 05:27:45 +00:00

Make 'yes' 1000 times faster.

This commit is contained in:
Valentin Lorentz 2017-10-21 21:23:06 +02:00
parent f2b952db54
commit fe87116431

View file

@ -22,6 +22,8 @@ use std::io::Write;
static NAME: &'static str = "yes";
static VERSION: &'static str = env!("CARGO_PKG_VERSION");
const BUF_SIZE: usize = 8192;
pub fn uumain(args: Vec<String>) -> i32 {
let mut opts = Options::new();
@ -51,7 +53,13 @@ pub fn uumain(args: Vec<String>) -> i32 {
matches.free.join(" ")
};
exec(&string[..]);
let mut multistring = string.clone();
while multistring.len() < BUF_SIZE - string.len() - 1 {
multistring.push_str("\n");
multistring.push_str(&string);
}
exec(&multistring[..]);
0
}