[diffoscope] 01/03: comparators.apk: Compile apkFileNmae regex instead of generating each loop.

Chris Lamb chris at chris-lamb.co.uk
Mon Jan 9 12:32:30 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 3f9ac451cfdaf64d24a4eaab82226d358a1549dc
Author: Chris Lamb <lamby at debian.org>
Date:   Mon Jan 9 11:29:08 2017 +0000

    comparators.apk: Compile apkFileNmae regex instead of generating each loop.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 diffoscope/comparators/apk.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/diffoscope/comparators/apk.py b/diffoscope/comparators/apk.py
index 8f70ec3..30e167e 100644
--- a/diffoscope/comparators/apk.py
+++ b/diffoscope/comparators/apk.py
@@ -93,10 +93,15 @@ class ApkFile(File):
 def filter_apk_metadata(filepath, archive_name):
     new_filename = os.path.join(os.path.dirname(filepath), "APK metadata")
     logger.debug("Moving APK metadata from %s to %s", filepath, new_filename)
+
+    re_filename = re.compile(
+        r'^apkFileName: %s' % re.escape(os.path.basename(archive_name)),
+    )
+
     with open(filepath) as f:
         with open(new_filename, "w") as f_out:
             for line in f:
-                if not re.match(r'^apkFileName: %s' % re.escape(os.path.basename(archive_name)), line):
+                if not re_filename.match(line):
                     f_out.write(line)
     os.remove(filepath)
     return new_filename

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


More information about the diffoscope mailing list