diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-08-22 02:25:20 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-08-22 20:05:11 +0200 |
| commit | d2c1430c91c574dc0dfd84f3652c8d9af8c77568 (patch) | |
| tree | 11c0d1a6a9ef28d538bcd963e80ee47395db6c5f /menuconfig.py | |
| parent | a3252f620fad970bbe8b7470401a04ee4225193e (diff) | |
Introduce Kconfig.unique_defined_syms and Kconfig.unique_choices
These are the same as Kconfig.defined_syms and Kconfig.choices, except
duplicates are removed. Kconfig order is still preserved.
This is almost always what you want when iterating through symbols and
choices, as it potentially saves work, avoids generating duplicates when
writing output, and still preserves Kconfig order for readability.
The old attributes will be kept for backwards compatibility (maybe
there's some rare cases where they could be useful too). They're created
internally anyway.
Diffstat (limited to 'menuconfig.py')
| -rwxr-xr-x | menuconfig.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/menuconfig.py b/menuconfig.py index 66ccca7..8f5dbe0 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -1565,14 +1565,12 @@ def _searched_nodes(cached_search_nodes=[]): # Returns a list of menu nodes to search, sorted by symbol name if not cached_search_nodes: - # Sort symbols by name and remove duplicates, then add all nodes for - # each symbol. - # - # Duplicates appear when symbols have multiple menu nodes (definition - # locations), but they appear in menu order, which isn't what we want - # here. We'd still need to go through sym.nodes as well. - for sym in sorted(set(_kconf.defined_syms), key=lambda sym: sym.name): - cached_search_nodes.extend(sym.nodes) + # Sort symbols by name, then add all nodes for each symbol + for sym in sorted(_kconf.unique_defined_syms, + key=lambda sym: sym.name): + + # += is in-place for lists + cached_search_nodes += sym.nodes return cached_search_nodes |
