summaryrefslogtreecommitdiff
path: root/kconfiglib.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2012-12-08 10:07:02 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2012-12-08 10:34:16 +0100
commit4aaa095d99832465f7bf0dbccaeb0f090c0dcae2 (patch)
tree2408610919cf72b76626c6abda874366c45092fd /kconfiglib.py
parent2b161c53532bc7d365910c9b1d73894b353f3ff3 (diff)
Cache the list of dependent symbols.
Will speed things up if a user value is set more than once on a symbol. Also, return the result as a list, which should be quicker to iterate through.
Diffstat (limited to 'kconfiglib.py')
-rw-r--r--kconfiglib.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index b7274d7..15a5c1c 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -2780,9 +2780,13 @@ class Symbol(Item, _HasVisibility):
# Should the symbol get an entry in .config?
self.write_to_conf = False
- # Stores the calculated value to avoid unnecessary recalculation
+ # Caches the calculated value
self.cached_value = None
+ # Caches the list of dependent symbols. Calculated the first time a
+ # user value is set on the symbol.
+ self.cached_deps = None
+
# Does the symbol have an entry in the Kconfig file? The Trailing
# underscore avoids a collision with is_defined().
self.is_defined_ = False
@@ -2928,6 +2932,10 @@ class Symbol(Item, _HasVisibility):
def _get_dependent(self):
"""Returns the list of symbols that should be invalidated if the value
of the symbol changes."""
+ if self.cached_deps is not None:
+ return self.cached_deps
+
+ # Calculate using a set to avoid duplicates in the result
res = set()
def rec(sym, ignore_choice = False):
@@ -2948,7 +2956,8 @@ class Symbol(Item, _HasVisibility):
rec(s, True)
rec(self)
- return res
+ self.cached_deps = list(res)
+ return self.cached_deps
def _has_auto_menu_dep_on(self, on):
"""See Choice._determine_actual_items()."""