changeset 44759:e58422afbc74 stable

diff: re-establish linear runtime performance The previous method with sum() and list() creates a new list object for every hunk. Then sum() is used to flatten out this sequence of lists. The sum() function is not "lazy", but creates a new list object for every "+" operation and so this code had quadratic runtime behaviour.
author Elmar Bartel <elb_hg@leo.org>
date Thu, 30 Apr 2020 15:10:05 +0200
parents a467416c493c
children 6a6c15cea1fa
files mercurial/patch.py
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Thu Apr 23 09:59:38 2020 +0200
+++ b/mercurial/patch.py	Thu Apr 30 15:10:05 2020 +0200
@@ -2558,7 +2558,7 @@
                 fctx2 is not None
             ), b'fctx2 unexpectly None in diff hunks filtering'
             hunks = hunksfilterfn(fctx2, hunks)
-        text = b''.join(sum((list(hlines) for hrange, hlines in hunks), []))
+        text = b''.join(b''.join(hlines) for hrange, hlines in hunks)
         if hdr and (text or len(hdr) > 1):
             yield b'\n'.join(hdr) + b'\n'
         if text: