mdiff: compute newlines-splitted texts within _unidiff
authorDenis Laxalde <denis.laxalde@logilab.fr>
Tue, 27 Sep 2016 20:27:35 +0200
changeset 31267 881ed6a4cf87
parent 31266 8089de5fab89
child 31268 4fba214708ee
mdiff: compute newlines-splitted texts within _unidiff There is no reason to compute splitted texts l1, l2 in unidiff() before calling _unidiff as they are only used with the latter function.
mercurial/mdiff.py
--- a/mercurial/mdiff.py	Wed Mar 08 18:32:42 2017 -0500
+++ b/mercurial/mdiff.py	Tue Sep 27 20:27:35 2016 +0200
@@ -240,9 +240,7 @@
         l3 = "@@ -1,%d +0,0 @@\n" % len(a)
         l = [l1, l2, l3] + ["-" + e for e in a]
     else:
-        al = splitnewlines(a)
-        bl = splitnewlines(b)
-        l = list(_unidiff(a, b, al, bl, opts=opts))
+        l = list(_unidiff(a, b, opts=opts))
         if not l:
             return ""
 
@@ -257,8 +255,9 @@
 
 # creates a headerless unified diff
 # t1 and t2 are the text to be diffed
-# l1 and l2 are the text broken up into lines
-def _unidiff(t1, t2, l1, l2, opts=defaultopts):
+def _unidiff(t1, t2, opts=defaultopts):
+    l1 = splitnewlines(t1)
+    l2 = splitnewlines(t2)
     def contextend(l, len):
         ret = l + opts.context
         if ret > len: