diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2015-06-20 12:32:02 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2015-06-20 20:08:17 +0200 |
| commit | 6ee0f9b9d740d45b580c8844514a0846ab54e8d1 (patch) | |
| tree | 3921d1238aa4ef4e6021e44863df4e30400bd596 /kconfiglib.py | |
| parent | 478a0644ef3d8332a7c21ef4e4de0ef10541af2c (diff) | |
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.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 27 |
1 files changed, 11 insertions, 16 deletions
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): |
