summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-10-09 03:50:54 +0000
committerZac Medico <zmedico@gentoo.org>2007-10-09 03:50:54 +0000
commit5a34eae5bf00b3289e5ce7c004e772fc51f5376b (patch)
tree82691c8b2a73ec2beb2955115c8a4ee137a8f8ae
parent4c0cf57979e7b344cc6f33c27e70228933ae41a9 (diff)
downloadportage-5a34eae5bf00b3289e5ce7c004e772fc51f5376b.tar.gz
portage-5a34eae5bf00b3289e5ce7c004e772fc51f5376b.tar.bz2
portage-5a34eae5bf00b3289e5ce7c004e772fc51f5376b.zip
Optimize away a match_from_list() call inside
portdbapi.xmatch("match-all") when given atom has no operator or version. Also, make cp_list() use the xmatch("match-all") cache when possible. svn path=/main/trunk/; revision=8008
-rw-r--r--pym/portage/dbapi/porttree.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index ee8c4776d..6ef737f8f 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -499,6 +499,10 @@ class portdbapi(dbapi):
return d.keys()
def cp_list(self, mycp, use_cache=1, mytree=None):
+ if self.frozen and mytree is None:
+ mylist = self.xcache["match-all"].get(mycp)
+ if mylist is not None:
+ return mylist[:]
mysplit = mycp.split("/")
invalid_category = mysplit[0] not in self._categories
d={}
@@ -519,8 +523,12 @@ class portdbapi(dbapi):
if invalid_category and d:
writemsg(("\n!!! '%s' has a category that is not listed in " + \
"/etc/portage/categories\n") % mycp, noiselevel=-1)
- return []
- return d.keys()
+ mylist = []
+ else:
+ mylist = d.keys()
+ if self.frozen and mytree is None:
+ self.xcache["match-all"][mycp] = mylist[:]
+ return mylist
def freeze(self):
for x in ["list-visible", "bestmatch-visible", "match-visible", "match-all"]:
@@ -573,8 +581,10 @@ class portdbapi(dbapi):
self.xmatch("list-visible", mykey, mydep=mykey, mykey=mykey))
elif level == "match-all":
#match *all* visible *and* masked packages
-
- myval = match_from_list(mydep, self.cp_list(mykey))
+ if mydep == mykey:
+ myval = self.cp_list(mykey)
+ else:
+ myval = match_from_list(mydep, self.cp_list(mykey))
else:
print "ERROR: xmatch doesn't handle", level, "query!"
raise KeyError