Skip to content

Commit

Permalink
More always inline
Browse files Browse the repository at this point in the history
  • Loading branch information
wcampbell0x2a committed Dec 28, 2023
1 parent 32f0172 commit 1f192c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion deku-derive/src/macros/deku_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ fn emit_enum(input: &DekuData) -> Result<TokenStream, syn::Error> {
tokens.extend(quote! {
#[allow(non_snake_case)]
impl #imp ::#crate_::DekuReader<#lifetime, #ctx_types> for #ident #wher {
#[inline(always)]
#[inline(always)]
fn from_reader_with_ctx<R: ::#crate_::no_std_io::Read>(__deku_reader: &mut ::#crate_::reader::Reader<R>, #ctx_arg) -> core::result::Result<Self, ::#crate_::DekuError> {
#read_body
}
Expand Down Expand Up @@ -414,6 +414,7 @@ fn emit_enum(input: &DekuData) -> Result<TokenStream, syn::Error> {
if let Some(deku_id_type) = deku_id_type {
tokens.extend(quote! {
impl #imp DekuEnumExt<#lifetime, (#deku_id_type)> for #ident #wher {
#[inline(always)]
fn deku_id(&self) -> core::result::Result<(#deku_id_type), DekuError> {
match self {
#(#deku_ids ,)*
Expand Down Expand Up @@ -786,11 +787,13 @@ pub fn emit_container_read(
quote! {
impl #imp ::#crate_::DekuContainerRead<#lifetime> for #ident #wher {
#[allow(non_snake_case)]
#[inline(always)]
fn from_reader<'a, R: ::#crate_::no_std_io::Read>(__deku_input: (&'a mut R, usize)) -> core::result::Result<(usize, Self), ::#crate_::DekuError> {
#from_reader_body
}

#[allow(non_snake_case)]
#[inline(always)]
fn from_bytes(__deku_input: (&#lifetime [u8], usize)) -> core::result::Result<((&#lifetime [u8], usize), Self), ::#crate_::DekuError> {
#from_bytes_body
}
Expand All @@ -810,6 +813,7 @@ pub fn emit_try_from(
impl #imp core::convert::TryFrom<&#lifetime [u8]> for #ident #wher {
type Error = ::#crate_::DekuError;

#[inline(always)]
fn try_from(input: &#lifetime [u8]) -> core::result::Result<Self, Self::Error> {
let total_len = input.len();
let mut cursor = ::#crate_::no_std_io::Cursor::new(input);
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ where
T: DekuWriter<Ctx>,
Ctx: Copy,
{
#[inline(always)]
fn to_writer<W: no_std_io::Write>(
&self,
writer: &mut Writer<W>,
Expand Down

0 comments on commit 1f192c7

Please sign in to comment.