From e29673faf69d7cf809736969b687e013193bd4fd Mon Sep 17 00:00:00 2001 From: Lucas Bollen Date: Wed, 28 Feb 2024 10:22:11 +0100 Subject: [PATCH] Add `inline` annotations to wrapping function calls in `ufmt` This should make the compiler inline the function calls to increase performance. --- CHANGELOG.md | 1 + Cargo.toml | 5 +++-- src/ufmt.rs | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2ff7a619b..0c7b7d6c65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Cargo.toml b/Cargo.toml index 05e42505a0..c9887c8995 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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] diff --git a/src/ufmt.rs b/src/ufmt.rs index c616b1efa3..e64e45d083 100644 --- a/src/ufmt.rs +++ b/src/ufmt.rs @@ -1,7 +1,9 @@ use crate::{storage::Storage, string::String, vec::VecInner}; +use ufmt::uDisplay; use ufmt_write::uWrite; impl uDisplay for String { + #[inline] fn fmt(&self, f: &mut ufmt::Formatter<'_, W>) -> Result<(), W::Error> where W: uWrite + ?Sized, @@ -12,6 +14,7 @@ impl uDisplay for String { impl uWrite for String { type Error = (); + #[inline] fn write_str(&mut self, s: &str) -> Result<(), Self::Error> { self.push_str(s) } @@ -19,6 +22,7 @@ impl uWrite for String { impl uWrite for VecInner { type Error = (); + #[inline] fn write_str(&mut self, s: &str) -> Result<(), Self::Error> { self.extend_from_slice(s.as_bytes()) }