-
Notifications
You must be signed in to change notification settings - Fork 152
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]
to lots of trivial functions.
#171
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @therealprof (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
#172 fixes (and/or silences) all other Clippy warnings, so Clippy can be enabled in CI. |
Now the only public non-inline functions left are: - write_all - write_aligned - All (derived) Debug implementations (Checked using Clippy's missing_inline_in_public_items lint.)
Overall this looks good! One question, have you done any test on the difference in size/perf. of optimized builds? |
I have no numbers and statistics for you, but I did look at the disassembly of a few projects I'm working on. Before this change, lots of trivial functions ended up as calls to functions that do nothing other than return a constant or write or read a single register. See also: |
Now with some numbers: For some random stm32 project I'm working at:
|
Also note that upstream Rust is doing the exact same thing for trivial functions. cf. rust-lang/rust#64996 Especially the |
Thanks for the update, then I say we merge this! |
bors r+ |
171: Add `#[inline]` to lots of trivial functions. r=korken89 a=m-ou-se Now the only public non-inline functions left are: - `write_all` - `write_aligned` - All (derived) `Debug` implementations (Checked using Clippy's [`missing_inline_in_public_items`][1] lint.) [1]: https://rust-lang.github.io/rust-clippy/master/#missing_inline_in_public_items Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
Build succeeded |
175: Enable the missing_inline_in_public_items clippy lint. r=jonas-schievink a=m-ou-se This adds `#![deny(clippy::missing_inline_in_public_items)]` to make sure all functions in this crate are marked `#[inline]`, unless they are explicitly marked with `#[allow(clippy::missing_inline_in_public_items)]`. Only three functions in this crate are not `#[inline]`: - `write_words` - `write_all` - `write_aligned` Additionally, the derived `Debug` impl's also have a non-inline implementations. This unfortunately means that the allow attribute also needs to added to any types deriving `Debug`. See also #171 and #174 (comment). Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
Now the only public non-inline functions left are:
write_all
write_aligned
Debug
implementations(Checked using Clippy's
missing_inline_in_public_items
lint.)