summaryrefslogtreecommitdiffstats
path: root/pym/portage.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-12-24 23:17:26 +0000
committerZac Medico <zmedico@gentoo.org>2006-12-24 23:17:26 +0000
commitb7b314de5416654f4fab195e43aee00cfc7efcbc (patch)
treeb9c78fdf9b536d4aebde5be93cbc9a5cd775b421 /pym/portage.py
parent12ba471d31dadbeba36a40268ef6363e38ec1cba (diff)
downloadportage-b7b314de5416654f4fab195e43aee00cfc7efcbc.tar.gz
portage-b7b314de5416654f4fab195e43aee00cfc7efcbc.tar.bz2
portage-b7b314de5416654f4fab195e43aee00cfc7efcbc.zip
Make bindbapi.aux_get() selectively cache metadata in order to optimize dep matching (like portdbapi does).
svn path=/main/trunk/; revision=5383
Diffstat (limited to 'pym/portage.py')
-rw-r--r--pym/portage.py48
1 files changed, 31 insertions, 17 deletions
diff --git a/pym/portage.py b/pym/portage.py
index a2970b2b4..b5e7820d1 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -4619,6 +4619,9 @@ class bindbapi(fakedbapi):
settings = globals()["settings"]
self.settings = settings
self._match_cache = {}
+ # Selectively cache metadata in order to optimize dep matching.
+ self._aux_cache_keys = set(["SLOT"])
+ self._aux_cache = {}
def match(self, *pargs, **kwargs):
if self.bintree and not self.bintree.populated:
@@ -4628,28 +4631,39 @@ class bindbapi(fakedbapi):
def aux_get(self,mycpv,wants):
if self.bintree and not self.bintree.populated:
self.bintree.populate()
+ cache_me = False
+ if not set(wants).difference(self._aux_cache_keys):
+ aux_cache = self._aux_cache.get(mycpv)
+ if aux_cache is not None:
+ return [aux_cache[x] for x in wants]
+ cache_me = True
mysplit = string.split(mycpv,"/")
mylist = []
tbz2name = mysplit[1]+".tbz2"
if self.bintree and not self.bintree.isremote(mycpv):
tbz2 = xpak.tbz2(self.bintree.getname(mycpv))
- for x in wants:
- if self.bintree and self.bintree.isremote(mycpv):
- # We use the cache for remote packages
- mylist.append(" ".join(
- self.bintree.remotepkgs[tbz2name].get(x,"").split()))
- else:
- myval = tbz2.getfile(x)
- if myval is None:
- myval = ""
- else:
- myval = string.join(myval.split(),' ')
- mylist.append(myval)
- if "EAPI" in wants:
- idx = wants.index("EAPI")
- if not mylist[idx]:
- mylist[idx] = "0"
- return mylist
+ getitem = tbz2.getfile
+ else:
+ getitem = self.bintree.remotepkgs[tbz2name].get
+ mydata = {}
+ mykeys = wants
+ if cache_me:
+ mykeys = self._aux_cache_keys.union(wants)
+ for x in mykeys:
+ myval = getitem(x)
+ # myval is None if the key doesn't exist
+ # or the tbz2 is corrupt.
+ if myval:
+ mydata[x] = " ".join(myval.split())
+ eapi = mydata.get("EAPI")
+ if eapi is not None and not eapi:
+ mydata["EAPI"] = "0"
+ if cache_me:
+ aux_cache = {}
+ for x in self._aux_cache_keys:
+ aux_cache[x] = mydata.get(x, "")
+ self._aux_cache[mycpv] = aux_cache
+ return [mydata.get(x, "") for x in wants]
def aux_update(self, cpv, values):
if not self.bintree.populated: