##// END OF EJS Templates
sparse-revlog: stop using a heap to track selected gap...
Boris Feld -
r40644:526ee887 default
parent child Browse files
Show More
@@ -10,7 +10,6 b''
10 from __future__ import absolute_import
10 from __future__ import absolute_import
11
11
12 import collections
12 import collections
13 import heapq
14 import struct
13 import struct
15
14
16 # import stuff from node for others to import from revlog
15 # import stuff from node for others to import from revlog
@@ -296,12 +295,11 b' def _slicechunktodensity(revlog, revs, t'
296 gaps.sort()
295 gaps.sort()
297
296
298 # Collect the indices of the largest holes until the density is acceptable
297 # Collect the indices of the largest holes until the density is acceptable
299 indicesheap = []
298 selected = []
300 heapq.heapify(indicesheap)
301 while gaps and density < targetdensity:
299 while gaps and density < targetdensity:
302 gapsize, gapidx = gaps.pop()
300 gapsize, gapidx = gaps.pop()
303
301
304 heapq.heappush(indicesheap, gapidx)
302 selected.append(gapidx)
305
303
306 # the gap sizes are stored as negatives to be sorted decreasingly
304 # the gap sizes are stored as negatives to be sorted decreasingly
307 # by the heap
305 # by the heap
@@ -310,11 +308,11 b' def _slicechunktodensity(revlog, revs, t'
310 density = chainpayload / float(readdata)
308 density = chainpayload / float(readdata)
311 else:
309 else:
312 density = 1.0
310 density = 1.0
311 selected.sort()
313
312
314 # Cut the revs at collected indices
313 # Cut the revs at collected indices
315 previdx = 0
314 previdx = 0
316 while indicesheap:
315 for idx in selected:
317 idx = heapq.heappop(indicesheap)
318
316
319 chunk = _trimchunk(revlog, revs, previdx, idx)
317 chunk = _trimchunk(revlog, revs, previdx, idx)
320 if chunk:
318 if chunk:
General Comments 0
You need to be logged in to leave comments. Login now