From 63b08f82786c187109a01665dc34b220418caa3f Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Mon, 28 Mar 2016 06:22:46 +0000 Subject: [PATCH] Optimise a few hints.search calls Signed-off-by: Niels Thykier --- britney.py | 4 ++-- policies/policy.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/britney.py b/britney.py index 4c5e380..d8182d5 100755 --- a/britney.py +++ b/britney.py @@ -1032,7 +1032,7 @@ class Britney(object): # version in testing, then stop here and return False # (as a side effect, a removal may generate such excuses for both the source # package and its binary packages on each architecture) - for hint in [x for x in self.hints.search('remove', package=src) if source_t[VERSION] == x.version]: + for hint in self.hints.search('remove', package=src, version=source_t[VERSION]): excuse.addhtml("Removal request by %s" % (hint.user)) excuse.addhtml("Trying to remove package, not update it") excuse.addhtml("Not considered") @@ -1435,7 +1435,7 @@ class Britney(object): update_candidate = False # check if there is a `force' hint for this package, which allows it to go in even if it is not updateable - forces = [x for x in self.hints.search('force', package=src) if source_u[VERSION] == x.version] + forces = self.hints.search('force', package=src, version=source_u[VERSION]) if forces: excuse.dontinvalidate = True if not update_candidate and forces: diff --git a/policies/policy.py b/policies/policy.py index 1b266a4..1f874ab 100644 --- a/policies/policy.py +++ b/policies/policy.py @@ -160,8 +160,8 @@ class AgePolicy(BasePolicy): age_info['age-requirement'] = min_days age_info['current-age'] = days_old - for age_days_hint in [x for x in self.hints.search('age-days', package=source_name) - if source_data_srcdist[VERSION] == x.version]: + for age_days_hint in self.hints.search('age-days', package=source_name, + version=source_data_srcdist[VERSION]): new_req = int(age_days_hint.days) age_info['age-requirement-reduced'] = { 'new-requirement': new_req, @@ -170,8 +170,8 @@ class AgePolicy(BasePolicy): min_days = new_req if days_old < min_days: - urgent_hints = [x for x in self.hints.search('urgent', package=source_name) - if source_data_srcdist[VERSION] == x.version] + urgent_hints = self.hints.search('urgent', package=source_name, + version=source_data_srcdist[VERSION]) if urgent_hints: age_info['age-requirement-reduced'] = { 'new-requirement': 0,