[PATCH 03 of 13] revlog: early return in _slicechunk when density is already good

Boris Feld boris.feld at octobus.net
Tue Jul 10 09:27:12 EDT 2018


# HG changeset patch
# User Paul Morelle <paul.morelle at octobus.net>
# Date 1529413438 -7200
#      Tue Jun 19 15:03:58 2018 +0200
# Node ID 639f8b092c12960f1a5f196326149099f98eb8db
# Parent  14c3643ceaf460b75dcd57866c5e5eca18e842d1
# EXP-Topic write-for-sparse-read
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 639f8b092c12
revlog: early return in _slicechunk when density is already good

We don't need to do anything if we know we won't enter the second while loop.
Save the overhead of the first loop by returning earlier.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -234,6 +234,10 @@ def _slicechunk(revlog, revs):
     else:
         density = 1.0
 
+    if density >= revlog._srdensitythreshold:
+        yield revs
+        return
+
     # Store the gaps in a heap to have them sorted by decreasing size
     gapsheap = []
     heapq.heapify(gapsheap)


More information about the Mercurial-devel mailing list