mirror of
https://github.com/sharkdp/hyperfine.git
synced 2024-09-11 14:07:02 +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 {
|
pub fn get_name_with_unused_parameters(&self) -> String {
|
||||||
let parameters = self
|
let parameters =
|
||||||
.get_unused_parameters()
|
self.get_unused_parameters()
|
||||||
.map(|(parameter, value)| format!("{} = {}, ", parameter, value.to_string()))
|
.fold(String::new(), |output, (parameter, value)| {
|
||||||
.collect::<String>();
|
output + &format!("{} = {}, ", parameter, value.to_string())
|
||||||
|
});
|
||||||
let parameters = parameters.trim_end_matches(", ");
|
let parameters = parameters.trim_end_matches(", ");
|
||||||
let parameters = if parameters.is_empty() {
|
let parameters = if parameters.is_empty() {
|
||||||
"".into()
|
"".into()
|
||||||
|
Loading…
Reference in New Issue
Block a user