diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-05-17 17:54:34 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-05-17 17:54:34 -0700 |
commit | c746e1246f6977c78b00b068e824e2066e66f0f1 (patch) | |
tree | 367a9d81b2a2f5809d2cba66f0d3f5bfc26f519a | |
parent | a9df8e0f5d49921974ed360a1277f14168aa5101 (diff) | |
download | portage-c746e1246f6977c78b00b068e824e2066e66f0f1.tar.gz portage-c746e1246f6977c78b00b068e824e2066e66f0f1.tar.bz2 portage-c746e1246f6977c78b00b068e824e2066e66f0f1.zip |
display_autounmask: optimize check_if_latest
-rw-r--r-- | pym/_emerge/depgraph.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 609b4d580..9fb0ceec8 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -5551,23 +5551,24 @@ class depgraph(object): dbs = self._dynamic_config._filtered_trees[pkg.root]["dbs"] root_config = self._frozen_config.roots[pkg.root] - all_cpv_by_slot = {} for db, pkg_type, built, installed, db_keys in dbs: for other_pkg in self._iter_match_pkgs(root_config, pkg_type, Atom(pkg.cp)): - slot = other_pkg.metadata["SLOT"] - all_cpv_by_slot.setdefault(slot, set()) - all_cpv_by_slot[slot].add(other_pkg.cpv) - - all_cpv = [] - for cpvs in all_cpv_by_slot.values(): - all_cpv.extend(cpvs) - all_cpv.sort(key=portage.versions.cpv_sort_key()) - - if all_cpv[-1] != pkg.cpv: - is_latest = False - slot_cpvs = sorted(all_cpv_by_slot[pkg.metadata["SLOT"]], key=portage.versions.cpv_sort_key()) - if slot_cpvs[-1] != pkg.cpv: - is_latest_in_slot = False + if other_pkg.cp != pkg.cp: + # old-style PROVIDE virtual means there are no + # normal matches for this pkg_type + break + if other_pkg > pkg: + is_latest = False + if other_pkg.slot_atom == pkg.slot_atom: + is_latest_in_slot = False + break + else: + # iter_match_pkgs yields highest verion first, so + # there's no need to search this pkg_type any further + break + + if not is_latest_in_slot: + break return is_latest, is_latest_in_slot |