Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion zlib-rs/src/inflate/bitreader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ impl<'a> BitReader<'a> {
// SAFETY: assertion above ensures we have 8 bytes to read for a u64.
let read = unsafe { core::ptr::read_unaligned(self.ptr.cast::<u64>()) }.to_le();
self.bit_buffer |= read << self.bits_used;
let increment = (63 - self.bits_used) >> 3;
// this xor was previously a subtraction but was changed for performance reasons.
// for bits_used between 0 and 63 (inclusive), it will always have the same behavior.
let increment = (63 ^ self.bits_used) >> 3;
self.ptr = self.ptr.wrapping_add(increment as usize);
self.bits_used |= 56;
}
Expand Down