[diffoscope] 01/02: diffoscope.diff: Avoid expensive regex parsing until we need it, speeding up diff parsing by 2X.

Chris Lamb chris at chris-lamb.co.uk
Tue Jan 3 18:06:15 CET 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit 0c14b97e5f41961c79655af5c05abbbedd366a68
Author: Chris Lamb <lamby at debian.org>
Date:   Tue Jan 3 16:52:41 2017 +0000

    diffoscope.diff: Avoid expensive regex parsing until we need it, speeding up diff parsing by 2X.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 diffoscope/diff.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/diffoscope/diff.py b/diffoscope/diff.py
index f4b9497..779ca0a 100644
--- a/diffoscope/diff.py
+++ b/diffoscope/diff.py
@@ -71,8 +71,6 @@ class DiffParser(object):
         self._output.close()
 
     def read_headers(self, line):
-        found = DiffParser.RANGE_RE.match(line)
-
         if not line:
             return None
 
@@ -82,6 +80,8 @@ class DiffParser(object):
         if line.startswith('+++'):
             return self.read_headers
 
+        found = DiffParser.RANGE_RE.match(line)
+
         if not found:
             raise ValueError('Unable to parse diff headers: %s' % repr(line))
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list