From a47615f06ad7e4d84ca1ab01db0520ef5f30010c Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Wed, 17 Apr 2019 14:43:06 +0200 Subject: 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. --- menuconfig.py | 13 ++++++++----- 1 file 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) -- cgit v1.2.3