changeset 40608:526ee887c4d5

sparse-revlog: stop using a heap to track selected gap Same logic as for 'gapsheap', we don't actually need a heap.
author Boris Feld <boris.feld@octobus.net>
date Thu, 08 Nov 2018 16:07:16 +0100
parents 54de23400b2a
children ee9981bc8b44
files mercurial/revlogutils/deltas.py
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlogutils/deltas.py	Thu Nov 08 16:01:30 2018 +0100
+++ b/mercurial/revlogutils/deltas.py	Thu Nov 08 16:07:16 2018 +0100
@@ -10,7 +10,6 @@
 from __future__ import absolute_import
 
 import collections
-import heapq
 import struct
 
 # import stuff from node for others to import from revlog
@@ -296,12 +295,11 @@
     gaps.sort()
 
     # Collect the indices of the largest holes until the density is acceptable
-    indicesheap = []
-    heapq.heapify(indicesheap)
+    selected = []
     while gaps and density < targetdensity:
         gapsize, gapidx = gaps.pop()
 
-        heapq.heappush(indicesheap, gapidx)
+        selected.append(gapidx)
 
         # the gap sizes are stored as negatives to be sorted decreasingly
         # by the heap
@@ -310,11 +308,11 @@
             density = chainpayload / float(readdata)
         else:
             density = 1.0
+    selected.sort()
 
     # Cut the revs at collected indices
     previdx = 0
-    while indicesheap:
-        idx = heapq.heappop(indicesheap)
+    for idx in selected:
 
         chunk = _trimchunk(revlog, revs, previdx, idx)
         if chunk: