summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-01-15 18:27:35 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2018-01-15 19:03:02 +0100
commit5d4c1842173239fac868278d3afa88131cc04c04 (patch)
tree2a3d8f6f239e8c0c7027b213b34e4bcc427d8881
parent401cd3c06af8f2812671aef157894d841c28726d (diff)
Get rid of 'keyword' assignment in _tokenize()
Also switch to a faster local lookup for the second _T_HELP. Micro-optimization -- shaves a % or two of the _tokenize() runtime. We expect a token for valid Kconfig files, so the naming is still fine.
-rw-r--r--kconfiglib.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index d91c27c..791d909 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -1233,20 +1233,19 @@ class Kconfig(object):
self._tokens_i = -1
return
- keyword = _get_keyword(initial_token_match.group(1))
+ token = _get_keyword(initial_token_match.group(1))
- if keyword == _T_HELP:
+ if token == _T_HELP:
# Avoid junk after "help", e.g. "---", being registered as a
# symbol
- self._tokens = (_T_HELP, None)
+ self._tokens = (token, None)
self._tokens_i = -1
return
- if keyword is None:
+ if token is None:
self._parse_error("expected keyword as first token")
- token = keyword
- self._tokens = [keyword]
+ self._tokens = [token]
# The current index in the string being tokenized
i = initial_token_match.end()