From 6ee0f9b9d740d45b580c8844514a0846ab54e8d1 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sat, 20 Jun 2015 12:32:02 +0200 Subject: Simplify _get_dependent(). - Inline _add_dependent_ignore_siblings(). - Copy the original 'dep' set and add the recursive dependencies to it instead of creating an initially empty set. No discernible performance improvement, but bit neater. --- kconfiglib.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'kconfiglib.py') diff --git a/kconfiglib.py b/kconfiglib.py index 121a8cc..bde4a2e 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -2483,28 +2483,23 @@ class Symbol(Item): if self.cached_deps is not None: return self.cached_deps - res = set() + res = set(self.dep) + for s in self.dep: + res |= s._get_dependent() - self._add_dependent_ignore_siblings(res) if self.is_choice_symbol_: - for s in self.parent.actual_symbols: - if s is not self: - res.add(s) - s._add_dependent_ignore_siblings(res) + # Choice symbols also depend (recursively) on their siblings. The + # siblings are not included in 'dep' to avoid dependency loops. + for sibling in self.parent.actual_symbols: + if sibling is not self: + res.add(sibling) + res |= sibling.dep + for s in sibling.dep: + res |= s._get_dependent() self.cached_deps = res return res - def _add_dependent_ignore_siblings(self, to): - """Calculating dependencies gets a bit tricky for choice items as they - all depend on each other, potentially leading to infinite recursion. - This helper function calculates dependencies ignoring the other symbols - in the choice. It also works fine for symbols that are not choice - items.""" - for s in self.dep: - to.add(s) - to |= s._get_dependent() - def _has_auto_menu_dep_on(self, on): """See Choice._determine_actual_symbols().""" if not isinstance(self.parent, Choice): -- cgit v1.2.3