Skip to content

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

Merged
tyranron merged 2 commits intomasterfrom
more-inline
Jan 23, 2024
Merged

Add #[inline] attribute to a few more methods#334
tyranron merged 2 commits intomasterfrom
more-inline

Conversation

@JelteF
Copy link
Copy Markdown
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
@JelteF JelteF added this to the 1.0.0 milestone Jan 22, 2024
@JelteF JelteF requested a review from tyranron January 22, 2024 21:08
@tyranron tyranron merged commit a7116ad into master Jan 23, 2024
@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