From c692a4b2df550d73de8cabaa1eabd5141bd8ce1c 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 + src/ufmt.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ce4857793..0d9fd807e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/ufmt.rs b/src/ufmt.rs index ca91ea7ef0..523de7cc35 100644 --- a/src/ufmt.rs +++ b/src/ufmt.rs @@ -3,6 +3,7 @@ use ufmt::uDisplay; use ufmt_write::uWrite; impl uDisplay for StringInner { + #[inline] fn fmt(&self, f: &mut ufmt::Formatter<'_, W>) -> Result<(), W::Error> where W: uWrite + ?Sized, @@ -13,6 +14,7 @@ impl uDisplay for StringInner { impl uWrite for StringInner { type Error = (); + #[inline] fn write_str(&mut self, s: &str) -> Result<(), Self::Error> { self.push_str(s) } @@ -20,6 +22,7 @@ impl uWrite for StringInner { impl uWrite for VecInner { type Error = (); + #[inline] fn write_str(&mut self, s: &str) -> Result<(), Self::Error> { self.extend_from_slice(s.as_bytes()) }