From: Zac Medico Date: Thu, 19 Feb 2009 19:01:26 +0000 (-0000) Subject: Optimize depgraph._dep_expand() to avoid calling pordbapi.cp_all(), X-Git-Tag: v2.2_rc24~156 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=35ce9db328c0727f4c246a0b9caa7fb02652d05b;p=portage.git Optimize depgraph._dep_expand() to avoid calling pordbapi.cp_all(), since it can be more efficient to call cp_list() on each category. Thanks to Marat Radchenko for the suggestion. svn path=/main/trunk/; revision=12653 --- diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index a5802bbe5..be50a6386 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -5274,23 +5274,14 @@ class depgraph(object): cat, atom_pn = portage.catsplit(null_cp) dbs = self._filtered_trees[root_config.root]["dbs"] - cp_set = set() + categories = set() for db, pkg_type, built, installed, db_keys in dbs: - cp_set.update(db.cp_all()) - for cp in list(cp_set): - cat, pn = portage.catsplit(cp) - if pn != atom_pn: - cp_set.discard(cp) + for cat in db.categories: + if db.cp_list("%s/%s" % (cat, atom_pn)): + categories.add(cat) + deps = [] - for cp in cp_set: - have_pkg = False - for db, pkg_type, built, installed, db_keys in dbs: - if db.cp_list(cp): - have_pkg = True - break - if not have_pkg: - continue - cat, pn = portage.catsplit(cp) + for cat in categories: deps.append(insert_category_into_atom( atom_without_category, cat)) return deps diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py index e5db363d7..dae7ad014 100644 --- a/pym/portage/dbapi/__init__.py +++ b/pym/portage/dbapi/__init__.py @@ -38,8 +38,7 @@ class dbapi(object): cat_pattern = re.compile(r'(.*)/.*') for cp in self.cp_all(): categories.add(cat_pattern.match(cp).group(1)) - self._categories = list(categories) - self._categories.sort() + self._categories = tuple(sorted(categories)) return self._categories def close_caches(self): diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 77e6ae494..d342c22d9 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -94,7 +94,7 @@ class portdbapi(dbapi): from portage import settings self.mysettings = config(clone=settings) self._iuse_implicit = self.mysettings._get_implicit_iuse() - self._categories = set(self.mysettings.categories) + self._categories = tuple(sorted(set(self.mysettings.categories))) # This is strictly for use in aux_get() doebuild calls when metadata # is generated by the depend phase. It's safest to use a clone for # this purpose because doebuild makes many changes to the config