@@ -145,37 +145,37 @@ type overfetchListItem struct {
145145}
146146
147147// MergeRanges takes a slice of SrcDstRanges, that:
148- // * is non-contiguous, and is sorted by NewOffset
148+ // * is non-contiguous, and is sorted by DstOffset
149149// * an Overfetch parameter
150150// - overfetch = 0.2 means we can request an extra 20%
151151// - overfetch = 1.00 means we can double our total transfer size
152152//
153- // Return a slice of OverfetchRanges
153+ // Return a list of OverfetchRanges
154154//
155155// Each OverfetchRange is one or more input ranges
156156// input ranges are merged in order of smallest byte distance to next range
157157// until the overfetch budget is consumed.
158- // The slice is sorted by Length
158+ // The list is sorted by Length
159159func MergeRanges (ranges []srcDstRange , overfetch float32 ) (* list.List , uint64 ) {
160160 totalSize := 0
161161
162162 shortest := make ([]* overfetchListItem , len (ranges ))
163163
164164 // create the heap items
165165 for i , rng := range ranges {
166- var bytesToNext uint64
166+ var bytesToNext int64
167167 if i == len (ranges )- 1 {
168- bytesToNext = math .MaxUint64
168+ bytesToNext = math .MaxInt64
169169 } else {
170- bytesToNext = ranges [i + 1 ].SrcOffset - (rng .SrcOffset + rng .Length )
170+ bytesToNext = int64 ( ranges [i + 1 ].SrcOffset ) - (int64 ( rng .SrcOffset ) + int64 ( rng .Length ) )
171171 if bytesToNext < 0 {
172- bytesToNext = math .MaxUint64
172+ bytesToNext = math .MaxInt64
173173 }
174174 }
175175
176176 shortest [i ] = & overfetchListItem {
177177 Rng : rng ,
178- BytesToNext : bytesToNext ,
178+ BytesToNext : uint64 ( bytesToNext ) ,
179179 CopyDiscards : []copyDiscard {{uint64 (rng .Length ), 0 }},
180180 }
181181 totalSize += int (rng .Length )
0 commit comments