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 authored and Dirbaio committed Jul 2, 2024
1 parent c67a764 commit c692a4b
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 @@ -83,6 +83,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`.

### Fixed

Expand Down
3 changes: 3 additions & 0 deletions src/ufmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use ufmt::uDisplay;
use ufmt_write::uWrite;

impl<S: Storage> uDisplay for StringInner<S> {
#[inline]
fn fmt<W>(&self, f: &mut ufmt::Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
Expand All @@ -13,13 +14,15 @@ impl<S: Storage> uDisplay for StringInner<S> {

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

0 comments on commit c692a4b

Please sign in to comment.