Skip to content

Commit

Permalink
tell the compiler which part of get_bits_triple is cold
Browse files Browse the repository at this point in the history
  • Loading branch information
KillingSpark committed Jun 21, 2022
1 parent 8a44192 commit 0155b30
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/decoding/bit_reader_reverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ impl<'s> BitReaderReversed<'s> {
Ok(self.get_bits_unchecked(n))
}

#[inline(always)]
pub fn get_bits_triple(&mut self, n1: u8, n2: u8, n3: u8) -> Result<(u64, u64, u64), String> {
let sum = n1 as usize + n2 as usize + n3 as usize;
if sum == 0 {
Expand Down Expand Up @@ -175,6 +176,11 @@ impl<'s> BitReaderReversed<'s> {
return Ok((v1, v2, v3));
}

self.get_bits_triple_cold(n1, n2, n3, sum)
}

#[cold]
fn get_bits_triple_cold(&mut self, n1: u8, n2: u8, n3: u8, sum: u8) -> Result<(u64, u64, u64), String>{
let sum_signed = sum as isize;

if self.bits_remaining() <= 0 {
Expand Down

0 comments on commit 0155b30

Please sign in to comment.