From 0e7de2a54b4330b352147f61fd1046142562ea83 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 12 Apr 2006 09:52:30 +0000 Subject: [PATCH] Use LazyItemsDict to avoid a vdb scan during portage import when autouse is enabled. svn path=/main/trunk/; revision=3135 --- pym/portage.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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: -- 2.26.2