Skip to content

Commit 03e413d

Browse files
committed
perf: debloats clap by deduplicating logic and refactors
This commit removes heavy use of macros in certain functions which drastically increased code size. Some of the macros could be turned into functions, while others could be removed entirely. Examples were removing arg_post_processing! which did things like checked overrides, requirements, groups, etc. This would happen after every argument was parsed. This macro also had several other macros inside it, and would expand to several tens or hundreds of lines of code. Then add that due to borrowck and branch issues, this macro may be included in multiple parts of a function. Unlike traditional functions each of these uses expanded into TONS of code (just like agressive inlining). This commit primarily removes those arg_post_processing! calls and breaks up the functionality into two types. The first must happen at ever new argument (not new value, but new argument). This is pretty cheap. The next type was moved to the end of parsing validation section which is more expensive, but only happens once. i.e. clap was validating each argument/value as it saw them, now it's lazy and validates them all at once at the end. This MUCH more efficient!
1 parent d26ab2b commit 03e413d

File tree

6 files changed

+324
-358
lines changed

6 files changed

+324
-358
lines changed

src/app/macros.rs

-165
This file was deleted.

0 commit comments

Comments
 (0)