1
0
Fork 0
mirror of https://codeberg.org/icewind/bitbuffer.git synced 2026-06-03 16:44:06 +02:00

minor cleanup

This commit is contained in:
Robin Appelman 2019-08-31 14:29:00 +02:00
commit e1079a412b

View file

@ -115,7 +115,7 @@ where
} else { } else {
container >> (usize_bit_size - bit_offset - count) container >> (usize_bit_size - bit_offset - count)
}; };
let mask = !(usize::max_value() << count); let mask = !(std::usize::MAX << count);
shifted & mask shifted & mask
} }
@ -193,6 +193,7 @@ where
T: PrimInt + BitOrAssign + IsSigned + UncheckedPrimitiveInt + BitXor, T: PrimInt + BitOrAssign + IsSigned + UncheckedPrimitiveInt + BitXor,
{ {
let type_bit_size = size_of::<T>() * 8; let type_bit_size = size_of::<T>() * 8;
let usize_bit_size = size_of::<usize>() * 8;
if type_bit_size < count { if type_bit_size < count {
return Err(ReadError::TooManyBits { return Err(ReadError::TooManyBits {
@ -215,9 +216,6 @@ where
} }
} }
let type_bit_size = size_of::<T>() * 8;
let usize_bit_size = size_of::<usize>() * 8;
let bit_offset = position & 7; let bit_offset = position & 7;
let fit_usize = count + bit_offset < usize_bit_size; let fit_usize = count + bit_offset < usize_bit_size;