Skip to content

Commit d62fce9

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

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
@@ -415,15 +415,17 @@ impl Cache {
415415
usize::try_from(offset).expect("offset larger than machine word bytes");
416416

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

421-
// Find which block this offset falls into
423+
let offset_within_cycle = current_offset % total_cycle_size;
422424
let mut block_start = 0;
423425
for block in blocks {
424426
let block_size = block.total_bytes.get() as usize;
425427
if offset_within_cycle < block_start + block_size {
426-
// Offset is within this block
428+
// Offset is within this block. Begin reading into `data`.
427429
let block_offset = offset_within_cycle - block_start;
428430
let bytes_in_block = (block_size - block_offset).min(remaining);
429431

0 commit comments

Comments
 (0)