Skip to content

Commit b511bc5

Browse files
authoredFeb 14, 2025
Use div_ceil instead of (x + 7) / 8 (#1624)
1 parent 0b00580 commit b511bc5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎downstairs/src/extent_inner_raw.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const DEFRAGMENT_THRESHOLD: u64 = 3;
5454
/// serialized using `bincode`.
5555
/// - Active context slots, stored as a bit-packed array (where 0 is
5656
/// [`ContextSlot::A`] and 1 is [`ContextSlot::B`]). This array contains
57-
/// `(extent_size + 7) / 8` bytes. It is only valid when the `dirty` bit is
57+
/// `extent_size.div_ceil(8)` bytes. It is only valid when the `dirty` bit is
5858
/// cleared. This is an optimization that speeds up opening a clean extent
5959
/// file; otherwise, we would have to rehash every block to find the active
6060
/// context slot.
@@ -1147,7 +1147,7 @@ impl RawLayout {
11471147
let block_count = self.block_count();
11481148
self.block_size().checked_mul(block_count).unwrap()
11491149
+ BLOCK_META_SIZE_BYTES
1150-
+ (block_count + 7) / 8
1150+
+ block_count.div_ceil(8)
11511151
+ BLOCK_CONTEXT_SLOT_SIZE_BYTES * block_count * 2
11521152
}
11531153

@@ -1180,7 +1180,7 @@ impl RawLayout {
11801180
}
11811181

11821182
fn active_context_size(&self) -> u64 {
1183-
(self.block_count() + 7) / 8
1183+
self.block_count().div_ceil(8)
11841184
}
11851185

11861186
fn metadata_offset(&self) -> u64 {

0 commit comments

Comments
 (0)