[PATCH 2 of 2] pure bdiff: don't use a generator
Dan Villiom Podlaski Christiansen
danchr at gmail.com
Sat Apr 30 08:48:09 CDT 2011
# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1304168736 -7200
# Node ID 912c73cb7fc37c196cf7d48176c04e34637bbfd9
# Parent 4d3431c22627b0c78f37885fadf6aba84d50343d
pure bdiff: don't use a generator
Generators are slow, and currently defeat the PyPy JIT.
diff --git a/mercurial/pure/bdiff.py b/mercurial/pure/bdiff.py
--- a/mercurial/pure/bdiff.py
+++ b/mercurial/pure/bdiff.py
@@ -19,6 +19,7 @@ def splitnewlines(text):
def _normalizeblocks(a, b, blocks):
prev = None
+ r = []
for curr in blocks:
if prev is None:
prev = curr
@@ -40,9 +41,10 @@ def _normalizeblocks(a, b, blocks):
while (b1end + shift < b2end and
a[a1end + shift] == b[b1end + shift]):
shift += 1
- yield a1, b1, l1 + shift
+ r.append((a1, b1, l1 + shift))
prev = a2 + shift, b2 + shift, l2 - shift
- yield prev
+ r.append(prev)
+ return r
def bdiff(a, b):
a = str(a).splitlines(True)
More information about the Mercurial-devel
mailing list