diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-10-12 06:19:17 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-10-12 06:19:17 +0000 |
commit | c1051a2d9ce9b37aedd7bfa1be4e9629fae0a55d (patch) | |
tree | c59439d64bb7c303ff688f371cdf5d1d0af6304d | |
parent | 37cef1df376d0ce279f769b6c9755011c73156cf (diff) | |
download | portage-c1051a2d9ce9b37aedd7bfa1be4e9629fae0a55d.tar.gz portage-c1051a2d9ce9b37aedd7bfa1be4e9629fae0a55d.tar.bz2 portage-c1051a2d9ce9b37aedd7bfa1be4e9629fae0a55d.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. (trunk r8008)
svn path=/main/branches/2.1.2/; revision=8066
-rw-r--r-- | pym/portage.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/pym/portage.py b/pym/portage.py index 447759c2b..8afd051ca 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -6477,7 +6477,11 @@ class portdbapi(dbapi): return d.keys() def cp_list(self, mycp, use_cache=1, mytree=None): - mysplit=mycp.split("/") + 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={} if mytree: @@ -6497,8 +6501,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"]: @@ -6546,7 +6554,10 @@ class portdbapi(dbapi): #get all visible packages, then get the matching ones 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 |