@@ -85,7 +85,7 @@ impl RoaringBitmap {
8585 let cookie = SERIAL_COOKIE as u32 | ( ( size as u32 - 1 ) << 16 ) ;
8686 writer. write_u32 :: < LittleEndian > ( cookie) ?;
8787 // It is then followed by a bitset indicating which containers are run containers
88- let run_container_bitmap_size = ( size + 7 ) / 8 ;
88+ let run_container_bitmap_size = size. div_ceil ( 8 ) ;
8989 let mut run_container_bitmap = vec ! [ 0 ; run_container_bitmap_size] ;
9090 for ( i, container) in self . containers . iter ( ) . enumerate ( ) {
9191 if let Store :: Run ( _) = container. store {
@@ -223,21 +223,21 @@ impl RoaringBitmap {
223223 let size = ( ( cookie >> 16 ) + 1 ) as usize ;
224224 ( size, size >= NO_OFFSET_THRESHOLD , true )
225225 } else {
226- return Err ( io:: Error :: new ( io :: ErrorKind :: Other , "unknown cookie value" ) ) ;
226+ return Err ( io:: Error :: other ( "unknown cookie value" ) ) ;
227227 }
228228 } ;
229229
230230 // Read the run container bitmap if necessary
231231 let run_container_bitmap = if has_run_containers {
232- let mut bitmap = vec ! [ 0u8 ; ( size + 7 ) / 8 ] ;
232+ let mut bitmap = vec ! [ 0u8 ; size. div_ceil ( 8 ) ] ;
233233 reader. read_exact ( & mut bitmap) ?;
234234 Some ( bitmap)
235235 } else {
236236 None
237237 } ;
238238
239239 if size > u16:: MAX as usize + 1 {
240- return Err ( io:: Error :: new ( io :: ErrorKind :: Other , "size is greater than supported" ) ) ;
240+ return Err ( io:: Error :: other ( "size is greater than supported" ) ) ;
241241 }
242242
243243 // Read the container descriptions
@@ -269,7 +269,7 @@ impl RoaringBitmap {
269269
270270 // If the run container bitmap is present, check if this container is a run container
271271 let is_run_container =
272- run_container_bitmap. as_ref ( ) . map_or ( false , |bm| bm[ i / 8 ] & ( 1 << ( i % 8 ) ) != 0 ) ;
272+ run_container_bitmap. as_ref ( ) . is_some_and ( |bm| bm[ i / 8 ] & ( 1 << ( i % 8 ) ) != 0 ) ;
273273
274274 let store = if is_run_container {
275275 let runs = reader. read_u16 :: < LittleEndian > ( ) ?;
@@ -329,7 +329,7 @@ fn header_size(size: usize, has_run_containers: bool) -> usize {
329329 if has_run_containers {
330330 // New format encodes the size (number of containers) into the 4 byte cookie
331331 // Additionally a bitmap is included marking which containers are run containers
332- let run_container_bitmap_size = ( size + 7 ) / 8 ;
332+ let run_container_bitmap_size = size. div_ceil ( 8 ) ;
333333 // New format conditionally includes offsets if there are 4 or more containers
334334 if size >= NO_OFFSET_THRESHOLD {
335335 COOKIE_BYTES + ( ( DESCRIPTION_BYTES + OFFSET_BYTES ) * size) + run_container_bitmap_size
0 commit comments