Skip to content

Commit c5afcea

Browse files
committed
Add inline for peek and drop, swich to first
Signed-off-by: Jakub Sztandera <[email protected]>
1 parent 0d2b7f5 commit c5afcea

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ipld/bitfield/src/rleplus/reader.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ impl<'a> BitReader<'a> {
4545

4646
/// Peeks a given number of bits from the buffer.Will keep returning 0 once
4747
/// the buffer has been exhausted.
48+
#[inline(always)]
4849
pub fn peek(&self, num_bits: u32) -> u8 {
4950
debug_assert!(num_bits <= 8);
5051

@@ -55,6 +56,7 @@ impl<'a> BitReader<'a> {
5556
}
5657

5758
/// Drops a number of bits from the buffer
59+
#[inline(always)]
5860
pub fn drop(&mut self, num_bits: u32) {
5961
debug_assert!(num_bits <= 8);
6062

@@ -64,7 +66,7 @@ impl<'a> BitReader<'a> {
6466

6567
// not sure why this being outside of the if improves the performance
6668
// bit it does, probably related to keeping caches warm
67-
let byte = self.bytes.get(0).unwrap_or(&0);
69+
let byte = self.bytes.first().unwrap_or(&0);
6870
self.bits |= (*byte as u64) << self.num_bits;
6971

7072
// if fewer than 8 bits remain, we skip to loading the next byte

0 commit comments

Comments
 (0)