diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2017-09-29 02:10:55 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2017-09-29 06:03:38 +0200 |
| commit | 35e8acdb2d49f279862a99ea129a9bb260b0bc4a (patch) | |
| tree | 9dc7ac9e5f2bd03ce5c21175d0d1e62cade6513f | |
| parent | f56ebf74f470431b0d262d2ce6f95d442b58f2f9 (diff) | |
Only invalidate defined symbols
Think I had it in the back of my head somewhere that not invalidating
undefined symbols could break some obscure cases, but turns out it's
perfectly safe: Nothing can change the value of an undefined symbol.
They always get their name as their value.
There's no need to unset user values on them either, because
set_user_value() already refuses to to set one on them.
Lets us get rid of the Python 2/3 compatibility hack and instead iterate
over a plain list of defined symbols.
| -rw-r--r-- | kconfiglib.py | 21 | ||||
| -rw-r--r-- | tests/Kchain | 3 |
2 files changed, 18 insertions, 6 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 5e8426b..be10efb 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -132,9 +132,6 @@ class Config(object): # The set of all symbols, indexed by name (a string) self._syms = {} - # Python 2/3 compatibility hack. This is the only one needed. - self._syms_iter = self._syms.values if sys.version_info[0] >= 3 else \ - self._syms.itervalues # The set of all defined symbols in the configuration in the order they # appear in the Kconfig files. This excludes the special symbols n, m, @@ -576,7 +573,12 @@ class Config(object): def unset_user_values(self): """Resets the values of all symbols, as if Config.load_config() or Symbol.set_user_value() had never been called.""" - for sym in self._syms_iter(): + + # set_user_value() already rejects undefined symbols, and they don't + # need to be invalidated (because their value never changes), so we can + # just iterate over defined symbols. + + for sym in self._kconfig_syms: # We're iterating over all symbols already, so no need for symbols # to invalidate their dependent symbols sym._unset_user_value_no_recursive_invalidate() @@ -1595,7 +1597,12 @@ class Config(object): # (these won't be included in _dep as that makes the dependency # graph unwieldy, but Symbol._get_dependent() will include them) # - Any symbols in a choice statement that depends on the symbol - for sym in self._syms_iter(): + + # Only calculate _dep for defined symbols. Undefined symbols could + # theoretically be selected/implied, but it wouldn't change their value + # (they always evaluate to their name), so it's not a true dependency. + + for sym in self._kconfig_syms: for _, e in sym._prompts: add_expr_deps(e, sym) @@ -1664,7 +1671,9 @@ class Config(object): return rec(expr) def _invalidate_all(self): - for sym in self._syms_iter(): + # Undefined symbols never change value and don't need to be + # invalidated, so we can just iterate over defined symbols + for sym in self._kconfig_syms: sym._invalidate() # diff --git a/tests/Kchain b/tests/Kchain index 643a949..d742c9e 100644 --- a/tests/Kchain +++ b/tests/Kchain @@ -75,6 +75,9 @@ config CHAIN_IMPLY_RELAY default y imply CHAIN_18 if CHAIN_17 +config CHAIN_18 + tristate "chain 19" + if CHAIN_18 = 0 config CHAIN_19 tristate "chain 19" |
