From bf03762630dd67e82df8531cb7aae358b1b5a7da Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Tue, 12 Jun 2018 21:18:58 +0200 Subject: Simplify _make_depend_on() Relations have the same format as AND/OR expressions and can be handled with the same code. This gives an extra recursion for relational expressions (because they can only have symbols as operands), but they're much rarer than other expression types. --- kconfiglib.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/kconfiglib.py b/kconfiglib.py index fcc2f43..29e0855 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -4566,25 +4566,17 @@ def _make_depend_on(sym, expr): # '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] in (AND, OR): - _make_depend_on(sym, expr[1]) - _make_depend_on(sym, expr[2]) - elif expr[0] == NOT: _make_depend_on(sym, expr[1]) - elif expr[0] in _RELATIONS: - if not expr[1].is_constant: - expr[1]._dependents.add(sym) - if not expr[2].is_constant: - expr[2]._dependents.add(sym) - else: - _internal_error("Internal error while fetching symbols from an " - "expression with token stream {}.".format(expr)) + # AND, OR, or relation + _make_depend_on(sym, expr[1]) + _make_depend_on(sym, expr[2]) def _expand(s): # A predefined UNAME_RELEASE symbol is expanded in one of the 'default's of -- cgit v1.2.3