Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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!
- Loading branch information