summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-06-12 21:18:58 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2018-06-12 21:21:04 +0200
commitbf03762630dd67e82df8531cb7aae358b1b5a7da (patch)
tree0bbc49b5284de9fa24d0148332f6d1e1056067c1
parent59b1a943953cb5c70acd2b5c65962f7d1c023626 (diff)
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.
-rw-r--r--kconfiglib.py16
1 files 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