From 5d4c1842173239fac868278d3afa88131cc04c04 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 15 Jan 2018 18:27:35 +0100 Subject: 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. --- kconfiglib.py | 11 +++++------ 1 file 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() -- cgit v1.2.3