revlog: avoid large yields in group()
authorMatt Mackall <mpm@selenic.com>
Thu, 11 Oct 2007 00:46:51 -0500
changeset 5448 e038738714fd
parent 5447 56591846f819
child 5449 17a4b20eda7b
revlog: avoid large yields in group() Split large yields so that the downstream consumer (chunkbuffer) will avoid some pain when reading ahead.
mercurial/revlog.py
--- a/mercurial/revlog.py	Thu Oct 11 00:46:49 2007 -0500
+++ b/mercurial/revlog.py	Thu Oct 11 00:46:51 2007 -0500
@@ -1096,7 +1096,14 @@
                 d = self.revdiff(a, b)
             yield changegroup.chunkheader(len(meta) + len(d))
             yield meta
-            yield d
+            if len(d) > 2**20:
+                pos = 0
+                while pos < len(d):
+                    pos2 = pos + 2 ** 18
+                    yield d[pos:pos2]
+                    pos = pos2
+            else:
+                yield d
 
         yield changegroup.closechunk()