Skip to content

Commit

Permalink
perf: debloats clap by deduplicating logic and refactors
Browse files Browse the repository at this point in the history
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
kbknapp committed Jan 9, 2018
1 parent d26ab2b commit 03e413d
Show file tree
Hide file tree
Showing 6 changed files with 324 additions and 358 deletions.
165 changes: 0 additions & 165 deletions src/app/macros.rs

This file was deleted.

Loading

0 comments on commit 03e413d

Please sign in to comment.