diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2017-11-04 20:38:24 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2017-11-04 21:08:53 +0100 |
| commit | de62a805582d804ab655a249e8ebdf1fe8c7c4fd (patch) | |
| tree | add940a66c0054b852c25fed7209bf8d8decb877 | |
| parent | 419f1bc50a04500761290d27c050996f9ba39e94 (diff) | |
Optimize tri_value() a bit
- Detect a 0 weak reverse dependency earlier. Being implied is
rare, and the direct deps don't need to be calculated for symbols
that aren't.
Bit cleaner too, and closer to the rev. dep code.
Shaves a few % off the time spent in tri_value() while writing a
.config.
- Look at the symbol's visibility to determine the choice mode instead
of going to the choice itself. Works since the mode acts as an upper
bound on the visibility of choice symbols. No detectable performance
difference, but a bit cleaner anyway.
Piggyback some nits.
| -rw-r--r-- | kconfiglib.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index f4672b7..9a6292e 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -2383,7 +2383,7 @@ class Symbol(object): vis = self.visibility self._write_to_conf = (vis != 0) - if self.choice is None: + if not self.choice: # Non-choice symbol if vis and self.user_value is not None: @@ -2397,17 +2397,16 @@ class Symbol(object): for default, cond in self.defaults: cond_val = expr_value(cond) if cond_val: - val = min(cond_val, expr_value(default)) + val = min(expr_value(default), cond_val) self._write_to_conf = True break # Weak reverse dependencies are only considered if our # direct dependencies are met - if expr_value(self.direct_dep): - weak_rev_dep_val = expr_value(self.weak_rev_dep) - if weak_rev_dep_val: - val = max(weak_rev_dep_val, val) - self._write_to_conf = True + weak_rev_dep_val = expr_value(self.weak_rev_dep) + if weak_rev_dep_val and expr_value(self.direct_dep): + val = max(weak_rev_dep_val, val) + self._write_to_conf = True # Reverse (select-related) dependencies take precedence rev_dep_val = expr_value(self.rev_dep) @@ -2421,14 +2420,15 @@ class Symbol(object): (self.type == BOOL or expr_value(self.weak_rev_dep) == 2): val = 2 - elif vis: - # Visible (bool/tristate) symbol in choice. See _get_visibility() - # for the other choice-specific stuff. - if self.choice.tri_value == 2: - val = 2 if self.choice.selection is self else 0 - elif self.user_value: - # mode == 1, user value available and not 0 - val = 1 + elif vis == 2: + # Visible choice symbol in y-mode choice. The choice mode limits + # the visibility of choice symbols, so it's sufficient to just + # check the visibility of the choice symbols themselves. + val = 2 if self.choice.selection is self else 0 + + elif vis and self.user_value: + # Visible choice symbol in m-mode choice, with set non-0 user value + val = 1 self._cached_tri_val = val return val |
