mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 13:07:46 +00:00
Merge pull request #1087 from ProgVal/faster-yes
Make 'yes' 1000 times faster.
This commit is contained in:
commit
ffc3c1d262
1 changed files with 9 additions and 1 deletions
|
@ -21,6 +21,8 @@ use getopts::Options;
|
||||||
static NAME: &'static str = "yes";
|
static NAME: &'static str = "yes";
|
||||||
static VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
static VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
|
const BUF_SIZE: usize = 8192;
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let mut opts = Options::new();
|
let mut opts = Options::new();
|
||||||
|
|
||||||
|
@ -50,7 +52,13 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
matches.free.join(" ")
|
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
|
0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue