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

perf(derive): reduce amount of generated code #4947

Merged
merged 1 commit into from Jun 2, 2023

Conversation

klensy
Copy link
Contributor

@klensy klensy commented Jun 2, 2023

Don't generate error string with format!, as there can be used concat!, reducing code size.

Example expanded code (from bindgen-cli) before:

                no_layout_tests: __clap_arg_matches
                    .remove_one::<bool>("no_layout_tests")
                    .ok_or_else(|| clap::Error::raw(
                        clap::error::ErrorKind::MissingRequiredArgument,
                        {
                            let res = ::alloc::fmt::format(
                                format_args!(
                                    "The following required argument was not provided: {0}",
                                    "no_layout_tests"
                                ),
                            );
                            res
                        },
                    ))?,

after:

                no_layout_tests: __clap_arg_matches
                    .remove_one::<bool>("no_layout_tests")
                    .ok_or_else(|| clap::Error::raw(
                        clap::error::ErrorKind::MissingRequiredArgument,
                        "The following required argument was not provided: no_layout_tests",
                    ))?,

This shave off ~10kb for bindgen-cli.

@epage
Copy link
Member

epage commented Jun 2, 2023

Thanks!

@epage epage merged commit 7ead9ab into clap-rs:master Jun 2, 2023
21 checks passed
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.

None yet

2 participants