diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2019-04-22 11:05:46 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2019-04-26 17:21:58 +0200 |
| commit | 6c7673e778db2fc50feaa3a0507026b15db33d38 (patch) | |
| tree | b3c6839817cbc0572cbacfc514a0eea0e363a532 | |
| parent | e1ff3de718a39959b79b4607e950d76c2486a44e (diff) | |
menuconfig: Use 'orig_type' instead of 'type' where possible
Symbol.type is only needed when there might be tristates demoted to
bools due to modules being disabled. Symbol.orig_type is faster to read
otherwise (no @property magic).
| -rwxr-xr-x | menuconfig.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/menuconfig.py b/menuconfig.py index cab3013..c502307 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -728,7 +728,7 @@ def _needs_save(): if sym.config_string: # Unwritten symbol return True - elif sym.type in (BOOL, TRISTATE): + elif sym.orig_type in (BOOL, TRISTATE): if sym.tri_value != sym.user_value: # Written bool/tristate symbol, new value return True @@ -1566,23 +1566,23 @@ def _change_node(node): # sc = symbol/choice sc = node.item - if sc.type in (INT, HEX, STRING): + if sc.orig_type in (INT, HEX, STRING): s = sc.str_value while True: s = _input_dialog( - "{} ({})".format(node.prompt[0], TYPE_TO_STR[sc.type]), + "{} ({})".format(node.prompt[0], TYPE_TO_STR[sc.orig_type]), s, _range_info(sc)) if s is None: break - if sc.type in (INT, HEX): + if sc.orig_type in (INT, HEX): s = s.strip() # 'make menuconfig' does this too. Hex values not starting with # '0x' are accepted when loading .config files though. - if sc.type == HEX and not s.startswith(("0x", "0X")): + if sc.orig_type == HEX and not s.startswith(("0x", "0X")): s = "0x" + s if _check_valid(sc, s): @@ -2952,8 +2952,7 @@ def _node_str(node): # Print "(NEW)" next to symbols without a user value (from e.g. a # .config), but skip it for choice symbols in choices in y mode, # and for symbols of UNKNOWN type (which generate a warning though) - if sym.user_value is None and \ - sym.type != UNKNOWN and \ + if sym.user_value is None and sym.orig_type and \ not (sym.choice and sym.choice.tri_value == 2): s += " (NEW)" @@ -3005,10 +3004,10 @@ def _value_str(node): return "" # Wouldn't normally happen, and generates a warning - if item.type == UNKNOWN: + if not item.orig_type: return "" - if item.type in (STRING, INT, HEX): + if item.orig_type in (STRING, INT, HEX): return "({})".format(item.str_value) # BOOL or TRISTATE @@ -3042,16 +3041,16 @@ def _check_valid(sym, s): # Returns True if the string 's' is a well-formed value for 'sym'. # Otherwise, displays an error and returns False. - if sym.type not in (INT, HEX): + if sym.orig_type not in (INT, HEX): # Anything goes for non-int/hex symbols return True - base = 10 if sym.type == INT else 16 + base = 10 if sym.orig_type == INT else 16 try: int(s, base) except ValueError: _error("'{}' is a malformed {} value" - .format(s, TYPE_TO_STR[sym.type])) + .format(s, TYPE_TO_STR[sym.orig_type])) return False for low_sym, high_sym, cond in sym.ranges: @@ -3075,7 +3074,7 @@ def _range_info(sym): # Returns a string with information about the valid range for the symbol # 'sym', or None if 'sym' doesn't have a range - if sym.type in (INT, HEX): + if sym.orig_type in (INT, HEX): for low, high, cond in sym.ranges: if expr_value(cond): return "Range: {}-{}".format(low.str_value, high.str_value) |
