summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-10-30 21:48:11 +0000
committerZac Medico <zmedico@gentoo.org>2007-10-30 21:48:11 +0000
commitd04efcdcc909361603d26d95452574647683bd5e (patch)
tree15273c540030d30ec548327d2f3bbbb37e53ece7 /pym
parent38fc97f83f41cf92ac4bb11b718ec098c4762802 (diff)
downloadportage-d04efcdcc909361603d26d95452574647683bd5e.tar.gz
portage-d04efcdcc909361603d26d95452574647683bd5e.tar.bz2
portage-d04efcdcc909361603d26d95452574647683bd5e.zip
Optimize xmatch "bestmatch-visible" to do fewer metadata
accesses by using the same code as "minimum-visible" but with a reverse iterator. svn path=/main/trunk/; revision=8342
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/dbapi/porttree.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index ec38e0850..aad388508 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -573,11 +573,6 @@ class portdbapi(dbapi):
#myval = self.visible(self.cp_list(mykey))
myval = self.gvisible(self.visible(self.cp_list(mykey)))
- elif level == "bestmatch-visible":
- #dep match -- best match of all visible packages
- #get all visible matches (from xmatch()), then choose the best one
-
- myval = best(self.xmatch("match-visible", None, mydep=mydep, mykey=mykey))
elif level == "minimum-all":
# Find the minimum matching version. This is optimized to
# minimize the number of metadata accesses (improves performance
@@ -598,7 +593,7 @@ class portdbapi(dbapi):
break
except KeyError:
pass # ebuild masked by corruption
- elif level == "minimum-visible":
+ elif level in ("minimum-visible", "bestmatch-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).
@@ -610,7 +605,11 @@ class portdbapi(dbapi):
mylist = match_from_list(mydep, self.cp_list(mykey))
myval = ""
settings = self.mysettings
- for cpv in mylist:
+ if level == "minimum-visible":
+ iterfunc = iter
+ else:
+ iterfunc = reversed
+ for cpv in iterfunc(mylist):
try:
metadata = dict(izip(self._aux_cache_keys,
self.aux_get(cpv, self._aux_cache_keys)))