Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Move off of HashMap/IndexMap to flat containers #4065

Merged
merged 3 commits into from
Aug 11, 2022

Conversation

epage
Copy link
Member

@epage epage commented Aug 11, 2022

For the number of items we manage, straight iteration is probably fast enough or faster and this reduces the amount of memory we use.

The map is modeled after the proposed version in C++ so that the keys are more likely to be in cache lines. If we ever add sorting to this, it'll get messy though. Since this is all internal, direct types are exposed rather than newtypes.

This is a good step towards #1365. The .text size dropped by 30.8KB according to

$ cargo bloat --features cargo --example cargo-example --release

While I didn't measure build times, things should be improved for #2037 because we are sending less code to LLVM.

This dropped `.text` by 14KB

Anything in debug asserts or help/usage output doesn't matter for
performance but I wouldn't be surprised if this was comparable since the
container sizes we are talking about are relatively small.
This dropped 17KB

Again, performance shouldn't be too bad as the total number of argument
id's passed in by the user shouldn't be huge, with the upper end being
5-15 except for in extreme cases like rustc accepting arguments from
cargo via a file.
@epage epage merged commit 084a6df into clap-rs:master Aug 11, 2022
@epage epage deleted the flat branch August 11, 2022 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant