Skip to content

Commit

Permalink
Add inline annotations to wrapping function calls in ufmt
Browse files Browse the repository at this point in the history
This should make the compiler inline the function calls to increase performance.
  • Loading branch information
lmbollen committed Jul 1, 2024
1 parent f27a3de commit 05b253f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- `ufmt-impl` is now `ufmt`
- `cas` is removed, atomic polyfilling is now opt-in via the `portable-atomic` feature.
- `Vec::as_mut_slice` is now a public method.
- `ufmt` functions are annotated with `inline(always)`.

### Fixed

Expand Down
3 changes: 3 additions & 0 deletions src/ufmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::{storage::Storage, string::String, vec::VecInner};
use ufmt_write::uWrite;

impl<const SIZE: usize> uDisplay for String<SIZE> {
#[inline(always)]
fn fmt<W>(&self, f: &mut ufmt::Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
Expand All @@ -12,13 +13,15 @@ impl<const SIZE: usize> uDisplay for String<SIZE> {

impl<const N: usize> uWrite for String<N> {
type Error = ();
#[inline(always)]
fn write_str(&mut self, s: &str) -> Result<(), Self::Error> {
self.push_str(s)
}
}

impl<S: Storage> uWrite for VecInner<u8, S> {
type Error = ();
#[inline(always)]
fn write_str(&mut self, s: &str) -> Result<(), Self::Error> {
self.extend_from_slice(s.as_bytes())
}
Expand Down

0 comments on commit 05b253f

Please sign in to comment.