summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-09-24 13:14:59 -0700
committerZac Medico <zmedico@gentoo.org>2011-09-24 13:14:59 -0700
commit97d2dac2cb7ee7ad33a31786eed74e1c204576dd (patch)
treed1e2eb00a573c1d598a8a585b625898bedf0e967
parentd3ad44b102f44aecdc0dc6ef951e853a9dd8dbbe (diff)
downloadportage-97d2dac2cb7ee7ad33a31786eed74e1c204576dd.tar.gz
portage-97d2dac2cb7ee7ad33a31786eed74e1c204576dd.tar.bz2
portage-97d2dac2cb7ee7ad33a31786eed74e1c204576dd.zip
portdbapi: tweak single-tree optimization
This optimizes aux_get and cp_list for cases where we only have a single tree, which is common for repoman and ebuild(1).
-rw-r--r--pym/portage/dbapi/porttree.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index d3cca00f5..42e5ca168 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -465,9 +465,16 @@ class portdbapi(dbapi):
if mytree is None:
raise KeyError(myrepo)
- if not mytree:
+ if mytree is not None and len(self.porttrees) == 1 \
+ and mytree == self.porttrees[0]:
+ # mytree matches our only tree, so it's safe to
+ # ignore mytree and cache the result
+ mytree = None
+ myrepo = None
+
+ if mytree is None:
cache_me = True
- if not mytree and not self._known_keys.intersection(
+ if mytree is None and not self._known_keys.intersection(
mylist).difference(self._aux_cache_keys):
aux_cache = self._aux_cache.get(mycpv)
if aux_cache is not None:
@@ -730,6 +737,14 @@ class portdbapi(dbapi):
return l
def cp_list(self, mycp, use_cache=1, mytree=None):
+
+ if self.frozen and mytree is not None \
+ and len(self.porttrees) == 1 \
+ and mytree == self.porttrees[0]:
+ # mytree matches our only tree, so it's safe to
+ # ignore mytree and cache the result
+ mytree = None
+
if self.frozen and mytree is None:
cachelist = self.xcache["cp-list"].get(mycp)
if cachelist is not None:
@@ -857,7 +872,7 @@ class portdbapi(dbapi):
# match *all* visible *and* masked packages
if mydep == mykey:
myval = self.cp_list(mykey, mytree=mytree)
- elif mydep.repo is not None or len(self.porttrees) == 1:
+ elif mydep.repo is not None:
myval = list(self._iter_match(mydep,
self.cp_list(mykey, mytree=mytree)))
else:
@@ -886,7 +901,7 @@ class portdbapi(dbapi):
if mydep == mykey:
for myval in self.cp_list(mykey, mytree=mytree):
break
- elif mydep.repo is not None or len(self.porttrees) == 1:
+ elif mydep.repo is not None:
for myval in self._iter_match(mydep,
self.cp_list(mykey, mytree=mytree)):
break
@@ -917,7 +932,7 @@ class portdbapi(dbapi):
else:
iterfunc = reversed
- if mydep.repo is not None or len(self.porttrees) == 1:
+ if mydep.repo is not None:
repos = [mydep.repo]
else:
# We iterate over self.porttrees, since it's common to
@@ -1010,9 +1025,7 @@ class portdbapi(dbapi):
aux_keys = list(self._aux_cache_keys)
metadata = {}
- if len(self.porttrees) == 1:
- repos = [None]
- elif myrepo is not None:
+ if myrepo is not None:
repos = [myrepo]
else:
# We iterate over self.porttrees, since it's common to