newBlockRange returns the block range for 'size' bytes from 'from'.
(from, length uint64)
| 62 | |
| 63 | // newBlockRange returns the block range for 'size' bytes from 'from'. |
| 64 | func newBlockRange(from, length uint64) blockRange { |
| 65 | end := from + length |
| 66 | return blockRange{ |
| 67 | start: int(from / BlockSize), |
| 68 | startOffset: from % BlockSize, |
| 69 | startLength: min(length, BlockSize-(from%BlockSize)), |
| 70 | last: int(end / BlockSize), |
| 71 | lastLength: end % BlockSize, |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // shrink resizes the data to a smaller length. |
| 76 | // Requirement: from > to. |