Skip to content
Myr

refactor: replace repeated string allocation

Before adoption: this commit came in with the history the project adopted, so no landing records it.

on each iteration with one `String` creation in `fold`, for efficiency

authored by Hamir Mahal · committed by David Peter · parent 09c39d8 · Browse files · 1 file+5 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−4 removed

  • other:+5 added−4 removed

1 file+5 added−4 removed

modified:src/command.rs+5 added-4 removed
57 unmodified lines
58 )59 }6061 pub fn get_name_with_unused_parameters(&self) -> String {62 let parameters = self63 .get_unused_parameters()64 .map(|(parameter, value)| format!("{} = {}, ", parameter, value.to_string()))65 .collect::<String>();62 let parameters =63 self.get_unused_parameters()64 .fold(String::new(), |output, (parameter, value)| {65 output + &format!("{} = {}, ", parameter, value.to_string())66 });67 let parameters = parameters.trim_end_matches(", ");68 let parameters = if parameters.is_empty() {69 "".into()70 } else {
495 unmodified lines