summaryrefslogtreecommitdiff
path: root/kconfiglib.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-11-26 03:43:31 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2018-11-26 05:44:52 +0100
commitbb7044cb39af5659c082bd74b45734dca64824c5 (patch)
tree3e7cf9f7226a4f9f3384d828114dfa4a823dd419 /kconfiglib.py
parent120f551b8bf9a6c35a9a97d5c7551bff66dc78bb (diff)
Reorder some tuples to put y first
CONFIG_FOO=y and 'default y' and the like are more common than the n versions, so test for them first. Turning the tuples into sets would be even better on Python 3, as it optimizes sets with constant keys into a LOAD_CONST, but it has a performance penalty on Python 2.
Diffstat (limited to 'kconfiglib.py')
-rw-r--r--kconfiglib.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index 838fbb7..89d5884 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -1100,9 +1100,9 @@ class Kconfig(object):
# The C implementation only checks the first character
# to the right of '=', for whatever reason
if not ((sym.orig_type is BOOL and
- val.startswith(("n", "y"))) or
+ val.startswith(("y", "n"))) or
(sym.orig_type is TRISTATE and
- val.startswith(("n", "m", "y")))):
+ val.startswith(("y", "m", "n")))):
self._warn("'{}' is not a valid value for the {} "
"symbol {}. Assignment ignored."
.format(val, TYPE_TO_STR[sym.orig_type],
@@ -1965,7 +1965,7 @@ class Kconfig(object):
i = match.end()
token = self.const_syms[name] \
- if name in ("n", "m", "y") else \
+ if name in ("y", "m", "n") else \
self._lookup_sym(name)
else:
@@ -4152,8 +4152,8 @@ class Symbol(object):
return True
# Check if the value is valid for our type
- if not (self.orig_type is BOOL and value in (0, 2, "n", "y") or
- self.orig_type is TRISTATE and value in (0, 1, 2, "n", "m", "y") or
+ if not (self.orig_type is BOOL and value in (2, 0, "y", "n") or
+ self.orig_type is TRISTATE and value in (2, 1, 0, "y", "m", "n") or
(value.__class__ is str and
(self.orig_type is STRING or
self.orig_type is INT and _is_base_n(value, 10) or
@@ -4170,7 +4170,7 @@ class Symbol(object):
return False
- if self.orig_type in _BOOL_TRISTATE and value in ("n", "m", "y"):
+ if self.orig_type in _BOOL_TRISTATE and value in ("y", "m", "n"):
value = STR_TO_TRI[value]
self.user_value = value
@@ -4767,8 +4767,8 @@ class Choice(object):
self._was_set = True
return True
- if not ((self.orig_type is BOOL and value in (0, 2, "n", "y") ) or
- (self.orig_type is TRISTATE and value in (0, 1, 2, "n", "m", "y"))):
+ if not ((self.orig_type is BOOL and value in (2, 0, "y", "n") ) or
+ (self.orig_type is TRISTATE and value in (2, 1, 0, "y", "m", "n"))):
# Display tristate values as n, m, y in the warning
self.kconfig._warn(
@@ -4781,7 +4781,7 @@ class Choice(object):
return False
- if value in ("n", "m", "y"):
+ if value in ("y", "m", "n"):
value = STR_TO_TRI[value]
self.user_value = value