summaryrefslogtreecommitdiff
path: root/kconfiglib.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-01-16 13:52:37 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2018-01-16 13:52:37 +0100
commitc054d89015a3fb600332de1590594d7eae539f32 (patch)
tree5b58c6bf2e8ab9bcfbecdb0f2bb05e4b1be7377e /kconfiglib.py
parent53e40850907fb181c15f177aa3358065d47898cf (diff)
Reset _tokens_i just once in _tokenize()
It's set to -1 in every return path, so we can just do it at the beginning instead.
Diffstat (limited to 'kconfiglib.py')
-rw-r--r--kconfiglib.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index 8eea9cf..f92c955 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -1223,23 +1223,23 @@ class Kconfig(object):
"""
s = self._line
- # Tricky implementation detail: While parsing a token, 'token' refers
- # to the previous token. See _STRING_LEX for why this is needed.
+ # Token index (minus one). Set for later -- not further updated here.
+ self._tokens_i = -1
# See comment at _initial_token_re_match definition
initial_token_match = _initial_token_re_match(s)
if not initial_token_match:
self._tokens = (None,)
- self._tokens_i = -1
return
+ # Tricky implementation detail: While parsing a token, 'token' refers
+ # to the previous token. See _STRING_LEX for why this is needed.
token = _get_keyword(initial_token_match.group(1))
if token == _T_HELP:
# Avoid junk after "help", e.g. "---", being registered as a
# symbol
self._tokens = (token, None)
- self._tokens_i = -1
return
if token is None:
@@ -1419,7 +1419,6 @@ class Kconfig(object):
# None-terminating token streams makes the token fetching functions
# simpler/faster
self._tokens.append(None)
- self._tokens_i = -1
def _next_token(self):
self._tokens_i += 1