From d2c1430c91c574dc0dfd84f3652c8d9af8c77568 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Wed, 22 Aug 2018 02:25:20 +0200 Subject: 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. --- menuconfig.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'menuconfig.py') 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 -- cgit v1.2.3