summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2016-08-06 23:49:57 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2016-08-06 23:55:06 +0200
commitfc59c2f9c0054e2279a36f33ccea2438abd8b1f2 (patch)
treea8a8d615466cafe88bbacd4fe9335aa68dbaa78d
parent28572e2f826859b01832cfab4f6d6950ce04fa40 (diff)
Micro-optimize parse_val_and_cond()
Saves a source line as well as some bytecode. Tuple evaluation is guaranteed to be from left to right: https://docs.python.org/2/reference/expressions.html#evaluation-order
-rw-r--r--kconfiglib.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index b279f57..23afdf5 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -804,11 +804,10 @@ class Config(object):
"""Parses '<expr1> if <expr2>' constructs, where the 'if' part is
optional. Returns a tuple containing the parsed expressions, with
None as the second element if the 'if' part is missing."""
- val = self._parse_expr(tokens, stmt, line, filename, linenr, False)
- if tokens.check(T_IF):
- return (val, self._parse_expr(tokens, stmt, line, filename,
- linenr))
- return (val, None)
+ return (self._parse_expr(tokens, stmt, line, filename, linenr,
+ False),
+ self._parse_expr(tokens, stmt, line, filename, linenr)
+ if tokens.check(T_IF) else None)
# In case the symbol is defined in multiple locations, we need to
# remember what prompts, defaults, and selects are new for this