diff --git a/src/lib.rs b/src/lib.rs index 8b16615..ee72bec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1304,30 +1304,27 @@ impl Iterator for StorageIter<'_, T> { #[inline(always)] /// How many bits are stored in each underlying storage block? -fn bits_per_block() -> usize { +const fn bits_per_block() -> usize { bytes_per_block::() * 8 } #[inline(always)] /// How many bytes are stored in each underlying storage block? -fn bytes_per_block() -> usize { +const fn bytes_per_block() -> usize { size_of::() } +#[inline(always)] /// Return the offset in the vector of the storage block storing the bit `off`. -fn block_offset(off: usize) -> usize { +const fn block_offset(off: usize) -> usize { off / bits_per_block::() } +#[inline(always)] /// Takes as input a number of bits requiring storage; returns an aligned number of blocks needed /// to store those bits. fn blocks_required(num_bits: usize) -> usize { - num_bits / bits_per_block::() - + if num_bits % bits_per_block::() == 0 { - 0 - } else { - 1 - } + num_bits / bits_per_block::() + usize::from(num_bits % bits_per_block::() != 0) } #[macro_export]