kconfig: helper function optimizations
Use the compat2enabled and label2node maps in the global edt object to
speed up some functions.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
diff --git a/scripts/kconfig/kconfigfunctions.py b/scripts/kconfig/kconfigfunctions.py
index 19ba25b..7a390a9 100644
--- a/scripts/kconfig/kconfigfunctions.py
+++ b/scripts/kconfig/kconfigfunctions.py
@@ -89,11 +89,9 @@
if doc_mode or edt is None:
return "n"
- for node in edt.nodes:
- if label in node.labels and node.enabled:
- return "y"
+ node = edt.label2node.get(label)
- return "n"
+ return "y" if node and node.enabled else "n"
def _node_reg_addr(node, index, unit):
@@ -317,11 +315,7 @@
if doc_mode or edt is None:
return "n"
- for node in edt.nodes:
- if compat in node.compats and node.enabled:
- return "y"
-
- return "n"
+ return "y" if compat in edt.compat2enabled else "n"
def dt_compat_on_bus(kconf, _, compat, bus):