[Reproducible-commits] [debbindiff] 01/02: Avoid unnecessary guess_mime_type calls

Jérémy Bobbio lunar at moszumanska.debian.org
Fri Jan 9 08:53:47 UTC 2015


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

lunar pushed a commit to branch master
in repository debbindiff.

commit cb6c61637690a164ca5f8e9fc4f1f25560ce901a
Author: Helmut Grohne <helmut at subdivi.de>
Date:   Fri Jan 9 00:01:48 2015 +0100

    Avoid unnecessary guess_mime_type calls
    
    Let's not call guess_mime_type for every comparator available. Doing it once
    should be enough.
---
 debbindiff/comparators/__init__.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/debbindiff/comparators/__init__.py b/debbindiff/comparators/__init__.py
index bf22bbb..765ad43 100644
--- a/debbindiff/comparators/__init__.py
+++ b/debbindiff/comparators/__init__.py
@@ -100,13 +100,13 @@ def compare_files(path1, path2, source=None):
         if file(path1).read() == file(path2).read():
             return []
     # ok, let's do the full thing
+    mime_type1 = guess_mime_type(path1)
+    mime_type2 = guess_mime_type(path2)
     for mime_type_regex, filename_regex, comparator in COMPARATORS:
         if filename_regex and re.search(filename_regex, path1) \
            and re.search(filename_regex, path2):
             return comparator(path1, path2, source)
         if mime_type_regex:
-            mime_type1 = guess_mime_type(path1)
-            mime_type2 = guess_mime_type(path2)
             if re.search(mime_type_regex, mime_type1) and \
                re.search(mime_type_regex, mime_type2):
                 return comparator(path1, path2, source)

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



More information about the Reproducible-commits mailing list