mirror of
https://codeberg.org/icewind/bitbuffer.git
synced 2026-06-03 16:44:06 +02:00
Check endianess when unconditionally reading boolean values
This commit is contained in:
parent
4a3d5820f8
commit
1e575b8efc
2 changed files with 16 additions and 2 deletions
|
|
@ -314,8 +314,13 @@ where
|
|||
let bit_offset = position & 7;
|
||||
|
||||
let byte = self.slice.get_unchecked(byte_index);
|
||||
let shifted = byte >> bit_offset;
|
||||
shifted & 1u8 == 1
|
||||
if E::is_le() {
|
||||
let shifted = byte >> bit_offset;
|
||||
shifted & 1u8 == 1
|
||||
} else {
|
||||
let shifted = byte << bit_offset;
|
||||
shifted & 0b1000_0000u8 == 0b1000_0000u8
|
||||
}
|
||||
}
|
||||
|
||||
/// Read a sequence of bits from the buffer as integer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue