diff --git a/src/reader/buffered_reader.rs b/src/reader/buffered_reader.rs index e40a1e98..1cbe3681 100644 --- a/src/reader/buffered_reader.rs +++ b/src/reader/buffered_reader.rs @@ -13,6 +13,7 @@ use crate::reader::{is_whitespace, BangType, Parser, Reader, Span, XmlSource}; macro_rules! impl_buffered_source { ($($lf:lifetime, $reader:tt, $async:ident, $await:ident)?) => { #[cfg(not(feature = "encoding"))] + #[inline] $($async)? fn remove_utf8_bom(&mut self) -> Result<()> { use crate::encoding::UTF8_BOM; @@ -31,6 +32,7 @@ macro_rules! impl_buffered_source { } #[cfg(feature = "encoding")] + #[inline] $($async)? fn detect_encoding(&mut self) -> Result> { loop { break match self $(.$reader)? .fill_buf() $(.$await)? { @@ -91,6 +93,7 @@ macro_rules! impl_buffered_source { Ok((&buf[start..], done)) } + #[inline] $($async)? fn read_with<$($lf,)? P: Parser>( &mut self, mut parser: P, @@ -133,6 +136,7 @@ macro_rules! impl_buffered_source { Err(Error::Syntax(P::eof_error())) } + #[inline] $($async)? fn read_bang_element $(<$lf>)? ( &mut self, buf: &'b mut Vec, @@ -183,6 +187,7 @@ macro_rules! impl_buffered_source { Err(bang_type.to_err()) } + #[inline] $($async)? fn skip_whitespace(&mut self, position: &mut usize) -> Result<()> { loop { break match self $(.$reader)? .fill_buf() $(.$await)? { @@ -202,6 +207,7 @@ macro_rules! impl_buffered_source { } } + #[inline] $($async)? fn skip_one(&mut self, byte: u8) -> Result { // search byte must be within the ascii range debug_assert!(byte.is_ascii()); @@ -215,6 +221,7 @@ macro_rules! impl_buffered_source { } } + #[inline] $($async)? fn peek_one(&mut self) -> Result> { loop { break match self $(.$reader)? .fill_buf() $(.$await)? { diff --git a/src/reader/slice_reader.rs b/src/reader/slice_reader.rs index 6dd5546c..d8da376d 100644 --- a/src/reader/slice_reader.rs +++ b/src/reader/slice_reader.rs @@ -237,6 +237,7 @@ impl<'a> Reader<&'a [u8]> { /// that will be borrowed by events. This implementation provides a zero-copy deserialization impl<'a> XmlSource<'a, ()> for &'a [u8] { #[cfg(not(feature = "encoding"))] + #[inline] fn remove_utf8_bom(&mut self) -> Result<()> { if self.starts_with(crate::encoding::UTF8_BOM) { *self = &self[crate::encoding::UTF8_BOM.len()..]; @@ -245,6 +246,7 @@ impl<'a> XmlSource<'a, ()> for &'a [u8] { } #[cfg(feature = "encoding")] + #[inline] fn detect_encoding(&mut self) -> Result> { if let Some((enc, bom_len)) = crate::encoding::detect_encoding(self) { *self = &self[bom_len..]; @@ -253,6 +255,7 @@ impl<'a> XmlSource<'a, ()> for &'a [u8] { Ok(None) } + #[inline] fn read_bytes_until( &mut self, byte: u8, @@ -275,6 +278,7 @@ impl<'a> XmlSource<'a, ()> for &'a [u8] { } } + #[inline] fn read_with

(&mut self, mut parser: P, _buf: (), position: &mut usize) -> Result<&'a [u8]> where P: Parser, @@ -291,6 +295,7 @@ impl<'a> XmlSource<'a, ()> for &'a [u8] { Err(Error::Syntax(P::eof_error())) } + #[inline] fn read_bang_element( &mut self, _buf: (), @@ -312,6 +317,7 @@ impl<'a> XmlSource<'a, ()> for &'a [u8] { Err(bang_type.to_err()) } + #[inline] fn skip_whitespace(&mut self, position: &mut usize) -> Result<()> { let whitespaces = self .iter() @@ -322,6 +328,7 @@ impl<'a> XmlSource<'a, ()> for &'a [u8] { Ok(()) } + #[inline] fn skip_one(&mut self, byte: u8) -> Result { // search byte must be within the ascii range debug_assert!(byte.is_ascii()); @@ -333,6 +340,7 @@ impl<'a> XmlSource<'a, ()> for &'a [u8] { } } + #[inline] fn peek_one(&mut self) -> Result> { Ok(self.first().copied()) }