Skip to content

Commit b173892

Browse files
committed
benchmarks: reduce allocations in run_util_function
1 parent 2d7a3bf commit b173892

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/uucore/src/lib/features/benchmark.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ pub fn run_util_function<F>(util_func: F, args: &[&str]) -> i32
3131
where
3232
F: FnOnce(std::vec::IntoIter<std::ffi::OsString>) -> i32,
3333
{
34+
let mut os_args = Vec::with_capacity(args.len() + 1);
3435
// Prepend a dummy program name as argv[0] since clap expects it
35-
let mut os_args: Vec<std::ffi::OsString> = vec!["benchmark".into()];
36-
os_args.extend(args.iter().map(|s| (*s).into()));
36+
os_args.push("benchmark".into());
37+
os_args.extend(args.iter().map(Into::into));
3738
util_func(os_args.into_iter())
3839
}
3940

0 commit comments

Comments
 (0)