mirror of
https://github.com/sharkdp/hyperfine.git
synced 2024-11-22 03:17:24 +03:00
refactor: replace repeated string allocation
on each iteration with one `String` creation in `fold`, for efficiency
This commit is contained in:
parent
09c39d8989
commit
6c774103d9
@ -59,10 +59,11 @@ impl<'a> Command<'a> {
|
||||
}
|
||||
|
||||
pub fn get_name_with_unused_parameters(&self) -> String {
|
||||
let parameters = self
|
||||
.get_unused_parameters()
|
||||
.map(|(parameter, value)| format!("{} = {}, ", parameter, value.to_string()))
|
||||
.collect::<String>();
|
||||
let parameters =
|
||||
self.get_unused_parameters()
|
||||
.fold(String::new(), |output, (parameter, value)| {
|
||||
output + &format!("{} = {}, ", parameter, value.to_string())
|
||||
});
|
||||
let parameters = parameters.trim_end_matches(", ");
|
||||
let parameters = if parameters.is_empty() {
|
||||
"".into()
|
||||
|
Loading…
Reference in New Issue
Block a user