Skip to content

Commit

Permalink
Add inline(always) to small DekuWriter functions
Browse files Browse the repository at this point in the history
  • Loading branch information
wcampbell0x2a committed Sep 15, 2023
1 parent a40dcfd commit 351eea4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/impls/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,18 +553,18 @@ macro_rules! ImplDekuWrite {

if matches!(endian, Endian::Little) {
for b in &mut input[..size.0 as usize] {
writer.write_bytes(&mut [*b])?;
writer.write_bytes(&[*b])?;
}
} else {
writer.write_bytes(&mut input[..size.0 as usize])?;
writer.write_bytes(&input[..size.0 as usize])?;
}
Ok(())
}
}

// Only have `endian`, return all input
impl DekuWrite<Endian> for $typ {
#[inline]
#[inline(always)]
fn write(
&self,
output: &mut BitVec<u8, Msb0>,
Expand All @@ -580,17 +580,17 @@ macro_rules! ImplDekuWrite {
}

impl DekuWriter<Endian> for $typ {
#[inline]
#[inline(always)]
fn to_writer<W: Write>(
&self,
writer: &mut Writer<W>,
endian: Endian,
) -> Result<(), DekuError> {
let mut input = match endian {
let input = match endian {
Endian::Little => self.to_le_bytes(),
Endian::Big => self.to_be_bytes(),
};
writer.write_bytes(&mut input)?;
writer.write_bytes(&input)?;
Ok(())
}
}
Expand Down

0 comments on commit 351eea4

Please sign in to comment.