Skip to content

Commit a03cff4

Browse files
committed
clarify comments
Signed-off-by: Brian L. Troutwine <[email protected]>
1 parent a0e0f8e commit a03cff4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: lading_payload/src/block.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,17 @@ impl Cache {
412412
usize::try_from(offset).expect("offset larger than machine word bytes");
413413

414414
while remaining > 0 {
415-
// Compute offset within the cycle
416-
let offset_within_cycle = current_offset % total_cycle_size;
415+
// The plan is this. We treat the blocks as one infinite cycle. We
416+
// map our offset into the domain of the blocks, then seek forward
417+
// until we find the block we need to start reading from. Then we
418+
// read into `data`.
417419

418-
// Find which block this offset falls into
420+
let offset_within_cycle = current_offset % total_cycle_size;
419421
let mut block_start = 0;
420422
for block in blocks {
421423
let block_size = block.total_bytes.get() as usize;
422424
if offset_within_cycle < block_start + block_size {
423-
// Offset is within this block
425+
// Offset is within this block. Begin reading into `data`.
424426
let block_offset = offset_within_cycle - block_start;
425427
let bytes_in_block = (block_size - block_offset).min(remaining);
426428

0 commit comments

Comments
 (0)