1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 12:37:49 +00:00

Merge pull request #1087 from ProgVal/faster-yes

Make 'yes' 1000 times faster.
This commit is contained in:
Alex Lyon 2017-12-30 23:40:20 -08:00 committed by GitHub
commit ffc3c1d262
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,6 +21,8 @@ use getopts::Options;
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();
@ -50,7 +52,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
}