diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2017-09-29 01:01:02 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2017-09-29 05:55:02 +0200 |
| commit | f56ebf74f470431b0d262d2ce6f95d442b58f2f9 (patch) | |
| tree | 61b40e1672b73484ae2890db799785fbf9c0db26 | |
| parent | e7c6c7a5f5ca20844cf23655a4a37fa7ccd6fc8f (diff) | |
Make _already_written local to write_config()
The clear loop in write_config() already guarantees that
_already_written will be set for all symbols that could be written out
to the .config. Clarifies the scope.
Also change the code to only clear _already_written for defined symbols.
No other symbols could ever be written out. Gives a nice loop over a
plain list.
| -rw-r--r-- | kconfiglib.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 21e978f..5e8426b 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -518,7 +518,18 @@ class Config(object): beginning of the file, with each line commented out automatically. None means no header.""" - for sym in self._syms_iter(): + # Symbol._already_written is set to True when _add_config_strings() is + # called on a symbol, so that symbols defined in multiple locations + # only get one .config entry. We reset it prior to writing out a new + # .config. It only needs to be reset for defined symbols, because + # undefined symbols will never have _add_config_strings() called on + # them (because they do not appear in the block structure rooted at + # _top_block). + # + # The C implementation reuses _write_to_conf for this, but we cache + # _write_to_conf together with the value and don't invalidate cached + # values when writing .config files, so that won't work. + for sym in self._kconfig_syms: sym._already_written = False # Build configuration. Avoiding string concatenation is worthwhile at @@ -2418,6 +2429,7 @@ class Symbol(Item): # don't need defaults: # _config # _name + # _already_written self._type = UNKNOWN self._prompts = [] @@ -2483,14 +2495,6 @@ class Symbol(Item): self._is_defined = False # Should the symbol get an entry in .config? self._write_to_conf = False - # Set to true when _add_config_strings() is called on a symbol, so that - # symbols defined in multiple locations only get one .config entry. We - # need to reset it prior to writing out a new .config. - # - # The C implementation reuses _write_to_conf for this, but we cache - # _write_to_conf together with the value and don't invalidate cached - # values writing .config files, so that won't work. - self._already_written = False # This is set to True for "actual" choice symbols; see # Choice._determine_actual_symbols(). self._is_choice_sym = False |
