summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-04-12 09:52:30 +0000
committerZac Medico <zmedico@gentoo.org>2006-04-12 09:52:30 +0000
commit0e7de2a54b4330b352147f61fd1046142562ea83 (patch)
tree926a9538176e067b37443caace22b6a74036778d
parentd1ede5959f39a95711a468345938fce7d903e5ed (diff)
downloadportage-0e7de2a54b4330b352147f61fd1046142562ea83.tar.gz
portage-0e7de2a54b4330b352147f61fd1046142562ea83.tar.bz2
portage-0e7de2a54b4330b352147f61fd1046142562ea83.zip
Use LazyItemsDict to avoid a vdb scan during portage import when autouse is enabled.
svn path=/main/trunk/; revision=3135
-rw-r--r--pym/portage.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/pym/portage.py b/pym/portage.py
index e5b251386..8c9584ea2 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -1402,8 +1402,26 @@ class config:
if mykey=="USE":
mydbs=self.uvlist
# XXX Global usage of db... Needs to go away somehow.
+ global db, root
if "auto" in self["USE_ORDER"].split(":") and db.has_key(root) and db[root].has_key("vartree"):
- self.configdict["auto"]["USE"]=autouse(db[root]["vartree"],use_cache=use_cache)
+ class LazyAutouse(object):
+ def __init__(self, *pargs, **kwargs):
+ self._use = None
+ self._pargs = pargs
+ self._kwargs = kwargs
+ def __call__(self):
+ if self._use is None:
+ global db, root
+ self._use = autouse(db[root]["vartree"], *self._pargs, **self._kwargs)
+ return self._use
+ if isinstance(self.configdict["auto"],
+ portage_util.LazyItemsDict):
+ lazy_values = self.configdict["auto"]
+ else:
+ lazy_values = portage_util.LazyItemsDict()
+ lazy_values.update(self.configdict["auto"])
+ lazy_values.addLazyItem("USE", LazyAutouse(use_cache=use_cache))
+ self.configdict["auto"] = lazy_values
else:
self.configdict["auto"]["USE"]=""
else: