forEachChunk invokes fn on a sequence of chunks that collectively span all bytes in fr. In each call, chunkFR is the subset of fr that falls within chunk. If any call to f returns false, forEachChunk stops iteration and returns.
(fr memmap.FileRange, fn func(chunk *chunkInfo, chunkFR memmap.FileRange) bool)
| 244 | // chunk. If any call to f returns false, forEachChunk stops iteration and |
| 245 | // returns. |
| 246 | func (f *MemoryFile) forEachChunk(fr memmap.FileRange, fn func(chunk *chunkInfo, chunkFR memmap.FileRange) bool) { |
| 247 | chunks := f.chunksLoad() |
| 248 | chunkStart := fr.Start &^ chunkMask |
| 249 | i := int(fr.Start / chunkSize) |
| 250 | for chunkStart < fr.End { |
| 251 | chunkEnd := chunkStart + chunkSize |
| 252 | if !fn(&chunks[i], fr.Intersect(memmap.FileRange{chunkStart, chunkEnd})) { |
| 253 | return |
| 254 | } |
| 255 | chunkStart = chunkEnd |
| 256 | i++ |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | // unwasteInfo is the value type of MemoryFile.unwasteSmall/Huge. |
| 261 | // |