perf: reduce memory allocation

This commit is contained in:
nibon7 2022-11-03 17:50:10 +08:00
parent 26fe5dbe96
commit a895ef3d4c
No known key found for this signature in database
GPG key ID: 281CE465D8EEC03B

View file

@ -207,12 +207,13 @@ fn generate_completion(completions: &mut String, cmd: &Command, is_subcommand: b
completions.push_str(format!(" export extern {} [\n", name).as_str());
}
let s: String = cmd
for s in cmd
.get_arguments()
.map(|arg| Argument::new(arg, name).to_string())
.collect();
{
completions.push_str(&s);
}
completions.push_str(&s);
completions.push_str(" ]\n\n");
if is_subcommand {