diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2015-06-04 04:09:14 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2015-06-04 05:22:01 +0200 |
| commit | 6c2a8e4ded047805d3289c59fc7b1bf55896ca84 (patch) | |
| tree | ad7bf8f01a89c21f7f29ef33dfa4aa7e5b9e20ec /kconfiglib.py | |
| parent | 8e77ba8bd7c13aa0b39fb991dca7175e793f17de (diff) | |
Check for AND before OR in _eval_expr_2().
Much more common, so make it the fast case.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 2a74d92..8dba935 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -1484,38 +1484,38 @@ error, and you should email ulfalizer a.t Google's email service.""" first_expr = expr[0] - if first_expr == OR: - res = "n" + if first_expr == AND: + res = "y" for subexpr in expr[1]: ev = self._eval_expr_2(subexpr) - # Return immediately upon discovering a "y" term - if ev == "y": - return "y" + # Return immediately upon discovering an "n" term + if ev == "n": + return "n" if ev == "m": res = "m" - # 'res' is either "n" or "m" here; we already handled the - # short-circuiting "y" case in the loop. + # 'res' is either "m" or "y" here; we already handled the + # short-circuiting "n" case in the loop. return res - if first_expr == AND: - res = "y" + if first_expr == OR: + res = "n" for subexpr in expr[1]: ev = self._eval_expr_2(subexpr) - # Return immediately upon discovering an "n" term - if ev == "n": - return "n" + # Return immediately upon discovering a "y" term + if ev == "y": + return "y" if ev == "m": res = "m" - # 'res' is either "m" or "y" here; we already handled the - # short-circuiting "n" case in the loop. + # 'res' is either "n" or "m" here; we already handled the + # short-circuiting "y" case in the loop. return res if first_expr == NOT: @@ -2193,7 +2193,7 @@ def _expr_to_str_rec(expr): e0 = expr[0] - if e0 == OR or e0 == AND: + if e0 == AND or e0 == OR: return _intersperse(expr[1], expr[0]) if e0 == NOT: |
