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 @@ -412,15 +412,17 @@ impl Cache {
412
412
usize:: try_from ( offset) . expect ( "offset larger than machine word bytes" ) ;
413
413
414
414
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`.
417
419
418
- // Find which block this offset falls into
420
+ let offset_within_cycle = current_offset % total_cycle_size ;
419
421
let mut block_start = 0 ;
420
422
for block in blocks {
421
423
let block_size = block. total_bytes . get ( ) as usize ;
422
424
if offset_within_cycle < block_start + block_size {
423
- // Offset is within this block
425
+ // Offset is within this block. Begin reading into `data`.
424
426
let block_offset = offset_within_cycle - block_start;
425
427
let bytes_in_block = ( block_size - block_offset) . min ( remaining) ;
426
428
You can’t perform that action at this time.
0 commit comments