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 e29673f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 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
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ mpmc_large = []
nightly = []

[dependencies]
portable-atomic = { version = "1.0", optional = true }
defmt = { version = ">=0.2.0,<0.4", optional = true }
hash32 = "0.3.0"
portable-atomic = { version = "1.0", optional = true }
serde = { version = "1", optional = true, default-features = false }
ufmt = "0.2"
ufmt-write = { version = "0.1", optional = true }
defmt = { version = ">=0.2.0,<0.4", optional = true }

# for the pool module
[target.'cfg(any(target_arch = "arm", target_pointer_width = "32", target_pointer_width = "64"))'.dependencies]
Expand Down
4 changes: 4 additions & 0 deletions src/ufmt.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::{storage::Storage, string::String, vec::VecInner};
use ufmt::uDisplay;
use ufmt_write::uWrite;

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

impl<const N: usize> uWrite for String<N> {
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 e29673f

Please sign in to comment.