diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-10-28 07:26:24 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-10-28 07:26:24 +0000 |
commit | 4ac207ffc70bb84a74d0b11d80864c5cdfa2ad32 (patch) | |
tree | 6dae73b638d9c844d6df3d20e69ca74979f28a9d /pym/portage/dbapi/virtual.py | |
parent | 2641d1772d8170f788d6ce8586b1f97a4506f04b (diff) | |
download | portage-4ac207ffc70bb84a74d0b11d80864c5cdfa2ad32.tar.gz portage-4ac207ffc70bb84a74d0b11d80864c5cdfa2ad32.tar.bz2 portage-4ac207ffc70bb84a74d0b11d80864c5cdfa2ad32.zip |
Sort all dbapi.cp_list() results in ascending order and
cache the results when possible. The order is preserved
in dbapi.match() so those results are also sorted.
svn path=/main/trunk/; revision=8329
Diffstat (limited to 'pym/portage/dbapi/virtual.py')
-rw-r--r-- | pym/portage/dbapi/virtual.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/pym/portage/dbapi/virtual.py b/pym/portage/dbapi/virtual.py index 65ac0a8d0..52aca6880 100644 --- a/pym/portage/dbapi/virtual.py +++ b/pym/portage/dbapi/virtual.py @@ -41,10 +41,17 @@ class fakedbapi(dbapi): return self.cpvdict.has_key(mycpv) def cp_list(self, mycp, use_cache=1): - if not self.cpdict.has_key(mycp): - return [] - else: - return self.cpdict[mycp] + cachelist = self._match_cache.get(mycp) + # cp_list() doesn't expand old-style virtuals + if cachelist and cachelist[0].startswith(mycp): + return cachelist[:] + cpv_list = self.cpdict.get(mycp) + if cpv_list is None: + cpv_list = [] + self._cpv_sort_ascending(cpv_list) + if not (not cpv_list and mycp.startswith("virtual/")): + self._match_cache[mycp] = cpv_list[:] + return cpv_list def cp_all(self): return list(self.cpdict) |