[Reproducible-commits] [misc] 01/01: convert some O(n^2) to O(n) in clean-notes; pretty cool that this is a problem

Chris West faux-guest at moszumanska.debian.org
Thu Feb 19 23:43:30 UTC 2015


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

faux-guest pushed a commit to branch master
in repository misc.

commit 96ccfbd58101bc6cedba4848024c4b8b85bf9be1
Author: Chris West (Faux) <git at goeswhere.com>
Date:   Thu Feb 19 23:42:56 2015 +0000

    convert some O(n^2) to O(n) in clean-notes; pretty cool that this is a problem
---
 clean-notes | 43 ++++++++++++++++++++-----------------------
 1 file changed, 20 insertions(+), 23 deletions(-)

diff --git a/clean-notes b/clean-notes
index 05ff8bf..c9ccc68 100755
--- a/clean-notes
+++ b/clean-notes
@@ -153,21 +153,20 @@ def load_reproducible_status():
     except FileNotFoundError:
         r = requests.get(reproducible_json)
         r = r.json()
-    return r
+    return dict(((item['package'], item) for item in r))
 
 
 def load_notes():
     with open(notes_yaml, encoding='utf-8') as fd:
-        notes = yaml.load(fd)
+        notes = yaml.safe_load(fd)
     return notes
 
 
 def check_notes_validity(notes, testedpkgs):
     failed = False
     badpkgs = []
-    allpkgs = [i['package'] for i in testedpkgs]
     for pkg in notes:
-        if pkg not in allpkgs:
+        if pkg not in testedpkgs:
             badpkgs.append(pkg)
             failed = True
             print('CRITICAL: the package ' + pkg +
@@ -217,25 +216,23 @@ def find_old_notes(testedpkgs, notes):
            'missing-version' not in args.disable:
             print("There is no version set for the package " + pkg)
             continue
-        for item in testedpkgs:
-            if item['package'] == pkg and \
-               item['version'] == notes[pkg].get('version') and \
-               item['status'] == 'reproducible'and \
-               'fixed-magically' not in args.disable:
-                print("The package " + pkg + " has a note for the version "
-                      + item['version'] + " but that version is reproducible")
-            if item['package'] == pkg and \
-               item['status'] == 'reproducible' and notes[pkg].get('version') and \
-               apt_pkg.version_compare(str(item['version']),
-                                       str(notes[pkg]['version'])) > 0:
-                print("The package " + pkg +
-                      " is now reproducible but still listed in the notes")
-                toremove.append(pkg)
-            if item['package'] == pkg and notes[pkg].get('version') and \
-               apt_pkg.version_compare(str(item['version']),
-                                       str(notes[pkg]['version'])) > 0:
-                if 'new-tested-version' not in args.disable:
-                    print("The package " + pkg + " has a new tested version")
+        item = testedpkgs[pkg]
+        if item['version'] == notes[pkg].get('version') and \
+            item['status'] == 'reproducible'and \
+            'fixed-magically' not in args.disable:
+            print("The package " + pkg + " has a note for the version "
+                    + item['version'] + " but that version is reproducible")
+        if item['status'] == 'reproducible' and notes[pkg].get('version') and \
+            apt_pkg.version_compare(str(item['version']),
+                                    str(notes[pkg]['version'])) > 0:
+            print("The package " + pkg +
+                    " is now reproducible but still listed in the notes")
+            toremove.append(pkg)
+        if notes[pkg].get('version') and \
+            apt_pkg.version_compare(str(item['version']),
+                                    str(notes[pkg]['version'])) > 0:
+            if 'new-tested-version' not in args.disable:
+                print("The package " + pkg + " has a new tested version")
     return toremove
 
 

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



More information about the Reproducible-commits mailing list