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 Feb 28, 2024
1 parent 7658d25 commit 572f4bd
Showing 1 changed file with 3 additions and 0 deletions.
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::{string::String, vec::Vec};
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<const N: usize> uWrite for Vec<u8, N> {
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 572f4bd

Please sign in to comment.