Skip to content

Commit

Permalink
Add #[inline] to Crc methods. (#12)
Browse files Browse the repository at this point in the history
With LTO off and codegen-units > 1, these are not always being inlined.
They ought to be.
  • Loading branch information
goffrie committed Oct 1, 2021
1 parent 515937f commit 25a1c74
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ const CRC_MAGIC: u16 = 31;
pub struct Crc(pub u32);

impl Crc {
#[inline]
fn split(self) -> (u16, u16) {
(self.0 as u16, (self.0 >> 16) as u16)
}

#[inline]
fn combine(s1: u16, s2: u16) -> Crc {
Crc(s1 as u32 | ((s2 as u32) << 16))
}

#[inline]
pub fn new() -> Crc {
Crc(0)
}
Expand All @@ -26,6 +29,7 @@ impl Crc {
Crc::combine(s1, s2)
}

#[inline]
pub fn rotate(self, size: u32, old_byte: u8, new_byte: u8) -> Crc {
let size = size as u16;
let old_byte = old_byte as u16;
Expand Down

0 comments on commit 25a1c74

Please sign in to comment.