mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
Merge pull request #4779 from epage/reserve
perf: Reduce alloc calls when building
This commit is contained in:
commit
f04ad2f38c
1 changed files with 2 additions and 0 deletions
|
@ -126,6 +126,8 @@ impl MKeyMap {
|
|||
/// We need a lazy build here since some we may change args after creating
|
||||
/// the map, you can checkout who uses `args_mut`.
|
||||
pub(crate) fn _build(&mut self) {
|
||||
// There will be at least as many keys as args, so that is a good starting point
|
||||
self.keys.reserve(self.args.len());
|
||||
for (i, arg) in self.args.iter().enumerate() {
|
||||
append_keys(&mut self.keys, arg, i);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue