From ffdb1a210c9854cf2e2467bf8a97ff894761a334 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Tue, 12 Jun 2018 21:30:11 +0200 Subject: Simplify _make_depend_on() some more Rearrange and break out common stuff. Already rename the 'sym' parameter to 'sc', as it could be a choice as well. --- kconfiglib.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'kconfiglib.py') diff --git a/kconfiglib.py b/kconfiglib.py index 29e0855..d480c96 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -4561,22 +4561,22 @@ def _visibility(sc): return vis -def _make_depend_on(sym, expr): - # Adds 'sym' as a dependency to all symbols in 'expr'. Constant symbols in - # 'expr' are skipped as they can never change value anyway. - - if not isinstance(expr, tuple): - # Symbol or choice - if not expr.is_constant: - expr._dependents.add(sym) - - elif expr[0] == NOT: - _make_depend_on(sym, expr[1]) - - else: - # AND, OR, or relation - _make_depend_on(sym, expr[1]) - _make_depend_on(sym, expr[2]) +def _make_depend_on(sc, expr): + # Adds 'sc' (symbol or choice) as a "dependee" to all symbols in 'expr'. + # Constant symbols in 'expr' are skipped as they can never change value + # anyway. + + if isinstance(expr, tuple): + # AND, OR, NOT or relation + _make_depend_on(sc, expr[1]) + + # NOTs only have a single operand + if expr[0] != NOT: + _make_depend_on(sc, expr[2]) + + elif not expr.is_constant: + # Non-constant symbol, or choice + expr._dependents.add(sc) def _expand(s): # A predefined UNAME_RELEASE symbol is expanded in one of the 'default's of -- cgit v1.2.3