From c0e897575e41ec4b8367e05d5d53f658ed0fcf8a Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 24 Sep 2011 14:31:48 -0700 Subject: portdbapi.xmatch: combine minimum-all/*-visible This eliminates redundant code. --- pym/portage/dbapi/porttree.py | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index d5068abd5..94b25e8e7 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -887,30 +887,8 @@ class portdbapi(dbapi): if len(myval) > 1: self._cpv_sort_ascending(myval) - elif level == "minimum-all": - # Find the minimum matching version. This is optimized to - # minimize the number of metadata accesses (improves performance - # especially in cases where metadata needs to be generated). - myval = "" - if mydep == mykey: - for myval in self.cp_list(mykey, mytree=mytree): - break - elif mydep.repo is not None: - for myval in self._iter_match(mydep, - self.cp_list(mykey, mytree=mytree)): - break - else: - # We iterate over self.porttrees, since it's common to - # tweak this attribute in order to adjust match behavior. - for tree in self.porttrees: - repo = self.repositories.get_name_for_location(tree) - for myval in self._iter_match(mydep.with_repo(repo), - self.cp_list(mykey, mytree=tree)): - break - if myval: - break - - elif level in ("match-visible", "minimum-visible", "bestmatch-visible"): + elif level in ("bestmatch-visible", "match-visible", + "minimum-all", "minimum-visible"): # Find the minimum matching visible version. This is optimized to # minimize the number of metadata accesses (improves performance # especially in cases where metadata needs to be generated). @@ -920,6 +898,7 @@ class portdbapi(dbapi): mylist = match_from_list(mydep, self.cp_list(mykey, mytree=mytree)) + visibility_filter = level != "minimum-all" single_match = level != "match-visible" myval = [] aux_keys = list(self._aux_cache_keys) @@ -946,7 +925,7 @@ class portdbapi(dbapi): # ebuild not in this repo, or masked by corruption continue - if not self._visible(cpv, metadata): + if visibility_filter and not self._visible(cpv, metadata): continue if mydep.slot is not None and \ -- cgit v1.2.3-1-g7c22