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

Add #[inline] attribute to a few more methods #334

Merged
merged 2 commits into from Jan 23, 2024
Merged

Add #[inline] attribute to a few more methods #334

merged 2 commits into from Jan 23, 2024

Conversation

JelteF
Copy link
Owner

@JelteF JelteF commented Jan 22, 2024

To be clear the #[inline] does not hint that inlining is beneficial,
but it does give the compiler the option to inline if the compiler
things it would be beneficial.

This starts adding the #[inline] attribute to:

  1. IsVariant: it's expected that this is often beneficial since its
    body is tiny.
  2. Debug: This is to stay in line with the std implementation of the
    Debug derive. Emit #[inline] on derive(Debug) rust-lang/rust#117727

It also explicitely doesn't add the attribute to the methods of Error,
since those are almost never called in hot code paths.

Fixes #317

To be clear the `#[inline]` does not hint that inlining is beneficial,
but it does give the compiler the option to inline if the compiler
things it would be beneficial.

This starts adding the `#[inline]` attribute to:

1. `IsVariant`: it's expected that this is often beneficial since its
   body is tiny.
2. `Debug`: This is to stay in line with the `std` implementation of the
   `Debug` derive. rust-lang/rust#117727

It also explicitely doesn't add the attribute to the methods of `Error`,
since those are almost never called in hot code paths.

Fixes #317
@tyranron tyranron merged commit a7116ad into master Jan 23, 2024
17 checks passed
@tyranron tyranron deleted the more-inline branch January 23, 2024 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use #[inline] attribute on Debug
2 participants