mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
chore: manual inline formatting
Minor manual cleanup - inlined many format args. This makes the code a bit more readable, and helps spot a few inefficiencies and possible bugs. Note that `&foo` in a `format!` parameter results in a 6% extra performance cost, and does not get inlined by the compiler (yet).
This commit is contained in:
parent
b7bf8c9467
commit
982805d3cd
29 changed files with 133 additions and 183 deletions
|
@ -138,28 +138,28 @@ fn generate_test_arg() -> String {
|
|||
if test_arg.arg_type == ArgType::INTEGER {
|
||||
arg.push_str(&format!(
|
||||
"{} {} {}",
|
||||
&rng.random_range(-100..=100).to_string(),
|
||||
rng.random_range(-100..=100).to_string(),
|
||||
test_arg.arg,
|
||||
&rng.random_range(-100..=100).to_string()
|
||||
rng.random_range(-100..=100).to_string()
|
||||
));
|
||||
} else if test_arg.arg_type == ArgType::STRINGSTRING {
|
||||
let random_str = generate_random_string(rng.random_range(1..=10));
|
||||
let random_str2 = generate_random_string(rng.random_range(1..=10));
|
||||
|
||||
arg.push_str(&format!(
|
||||
"{} {} {}",
|
||||
&random_str, test_arg.arg, &random_str2
|
||||
"{random_str} {} {random_str2}",
|
||||
test_arg.arg,
|
||||
));
|
||||
} else if test_arg.arg_type == ArgType::STRING {
|
||||
let random_str = generate_random_string(rng.random_range(1..=10));
|
||||
arg.push_str(&format!("{} {}", test_arg.arg, &random_str));
|
||||
arg.push_str(&format!("{} {random_str}", test_arg.arg));
|
||||
} else if test_arg.arg_type == ArgType::FILEFILE {
|
||||
let path = generate_random_path(&mut rng);
|
||||
let path2 = generate_random_path(&mut rng);
|
||||
arg.push_str(&format!("{} {} {}", path, test_arg.arg, path2));
|
||||
arg.push_str(&format!("{path} {} {path2}", test_arg.arg));
|
||||
} else if test_arg.arg_type == ArgType::FILE {
|
||||
let path = generate_random_path(&mut rng);
|
||||
arg.push_str(&format!("{} {}", test_arg.arg, path));
|
||||
arg.push_str(&format!("{} {path}", test_arg.arg));
|
||||
}
|
||||
}
|
||||
4 => {
|
||||
|
@ -176,7 +176,7 @@ fn generate_test_arg() -> String {
|
|||
.collect();
|
||||
|
||||
if let Some(test_arg) = file_test_args.choose(&mut rng) {
|
||||
arg.push_str(&format!("{}{}", test_arg.arg, path));
|
||||
arg.push_str(&format!("{}{path}", test_arg.arg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue