Commit e3a4c9d
perf: remove unnecessary clone in set_subcommand_ancestors
Replace `ancestors.to_vec()` followed by `ancestors.clone().into_iter()`
with direct `ancestors.iter().cloned()`. This eliminates two Vec allocations
per recursion level (one for the to_vec() and one for each subcommand's clone()).
The improvement:
- Before: O(n) Vec allocation for to_vec() + O(n) Vec allocation per subcommand
- After: O(n) lazy iteration with element-by-element cloning (no intermediate Vec)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1 parent 9df7c86 commit e3a4c9d
1 file changed
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
313 | 312 | | |
314 | 313 | | |
315 | | - | |
316 | | - | |
| 314 | + | |
| 315 | + | |
317 | 316 | | |
318 | 317 | | |
319 | | - | |
| 318 | + | |
| 319 | + | |
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| |||
0 commit comments