We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 803e865 commit eba950dCopy full SHA for eba950d
src/bit_vec/fast_rs_vec/mod.rs
@@ -373,10 +373,8 @@ impl RsVec {
373
pub fn get_bits_unchecked(&self, pos: usize, len: usize) -> u64 {
374
debug_assert!(len <= WORD_SIZE);
375
let partial_word = self.data[pos / WORD_SIZE] >> (pos % WORD_SIZE);
376
- if pos % WORD_SIZE + len == WORD_SIZE {
377
- partial_word
378
- } else if pos % WORD_SIZE + len < WORD_SIZE {
379
- partial_word & ((1 << (len % WORD_SIZE)) - 1)
+ if pos % WORD_SIZE + len <= WORD_SIZE {
+ partial_word & 1u64.checked_shl(len as u32).unwrap_or(0).wrapping_sub(1)
380
} else {
381
(partial_word | (self.data[pos / WORD_SIZE + 1] << (WORD_SIZE - pos % WORD_SIZE)))
382
& 1u64.checked_shl(len as u32).unwrap_or(0).wrapping_sub(1)
0 commit comments