Skip to content

Commit 6fb54c4

Browse files
committed
try_into().unwrap() is faster than .read_exact() to get a [u8; 8] from a &[u8]
1 parent 62782e2 commit 6fb54c4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/decoding/bit_reader_reverse.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use core::convert::TryInto;
2+
13
pub use super::bit_reader::GetBitsError;
24
use crate::io::Read;
35

@@ -52,8 +54,7 @@ impl<'s> BitReaderReversed<'s> {
5254
#[inline(always)]
5355
fn refill_fast(&mut self, byte_idx: usize, retain_bytes: u8, want_to_read_bits: u8) {
5456
let load_from_byte_idx = byte_idx - 7 + retain_bytes as usize;
55-
let mut tmp_bytes = [0; 8];
56-
let _ = (&self.source[load_from_byte_idx..]).read_exact(&mut tmp_bytes);
57+
let tmp_bytes: [u8; 8] = (&self.source[load_from_byte_idx..][..8]).try_into().unwrap();
5758
let refill = u64::from_le_bytes(tmp_bytes);
5859
self.bit_container = refill;
5960
self.bits_in_container += want_to_read_bits;

0 commit comments

Comments
 (0)