File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -415,15 +415,17 @@ impl Cache {
415
415
usize:: try_from ( offset) . expect ( "offset larger than machine word bytes" ) ;
416
416
417
417
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`.
420
422
421
- // Find which block this offset falls into
423
+ let offset_within_cycle = current_offset % total_cycle_size ;
422
424
let mut block_start = 0 ;
423
425
for block in blocks {
424
426
let block_size = block. total_bytes . get ( ) as usize ;
425
427
if offset_within_cycle < block_start + block_size {
426
- // Offset is within this block
428
+ // Offset is within this block. Begin reading into `data`.
427
429
let block_offset = offset_within_cycle - block_start;
428
430
let bytes_in_block = ( block_size - block_offset) . min ( remaining) ;
429
431
You can’t perform that action at this time.
0 commit comments