diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2019-04-17 14:43:06 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2019-04-17 15:13:31 +0200 |
| commit | a47615f06ad7e4d84ca1ab01db0520ef5f30010c (patch) | |
| tree | 76ce54be19e30eaa32bf74b42da1bbabbe9519c3 /menuconfig.py | |
| parent | e4f268157254df1ef361763bcfdf0258818fa53d (diff) | |
menuconfig: Prune _shown_nodes() recursion
When looking for visible children of invisible symbol nodes,
_shown_nodes() was always recursing all the way out the leaf nodes.
That's a ton of redundant work, though it doesn't seem to have lead to
noticeable slowness (it does in the GUI menuconfig).
Stop the search at symbol nodes with node.dep = n (from
'if'/'depends on'). Those can never have visible children, because
node.dep gets propagated to prompts.
Diffstat (limited to 'menuconfig.py')
| -rwxr-xr-x | menuconfig.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/menuconfig.py b/menuconfig.py index 2072186..824920d 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -1470,11 +1470,14 @@ def _shown_nodes(menu): # menus and choices as well as 'menuconfig' symbols. res += rec(node.list) - elif node.list and isinstance(node.item, Symbol): - # Show invisible symbols (defined with either 'config' and - # 'menuconfig') if they have visible children. This can happen - # for an m/y-valued symbol with an optional prompt ('prompt - # "foo" is COND') that is currently disabled. + elif node.list and isinstance(node.item, Symbol) and \ + expr_value(node.dep): + # Show invisible symbols if they have visible children. This + # can happen for an m/y-valued symbol with an optional prompt + # ('prompt "foo" is COND') that is currently disabled. The + # expr_value(node.dep) check safely prunes the search: A node + # with unsatisfied direct dependencies can never have visible + # children. shown_children = rec(node.list) if shown_children: res.append(node) |
