From d165859c76427fd939e2b934bc5a4ab3b4115397 Mon Sep 17 00:00:00 2001 From: "Brian L. Troutwine" Date: Wed, 16 Oct 2024 17:43:06 -0700 Subject: [PATCH] clarify comments Signed-off-by: Brian L. Troutwine --- lading_payload/src/block.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lading_payload/src/block.rs b/lading_payload/src/block.rs index 77ae53439..443d8f8e4 100644 --- a/lading_payload/src/block.rs +++ b/lading_payload/src/block.rs @@ -412,15 +412,17 @@ impl Cache { usize::try_from(offset).expect("offset larger than machine word bytes"); while remaining > 0 { - // Compute offset within the cycle - let offset_within_cycle = current_offset % total_cycle_size; + // The plan is this. We treat the blocks as one infinite cycle. We + // map our offset into the domain of the blocks, then seek forward + // until we find the block we need to start reading from. Then we + // read into `data`. - // Find which block this offset falls into + let offset_within_cycle = current_offset % total_cycle_size; let mut block_start = 0; for block in blocks { let block_size = block.total_bytes.get() as usize; if offset_within_cycle < block_start + block_size { - // Offset is within this block + // Offset is within this block. Begin reading into `data`. let block_offset = offset_within_cycle - block_start; let bytes_in_block = (block_size - block_offset).min(remaining);