diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2015-06-17 16:28:15 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2015-06-17 16:29:44 +0200 |
| commit | b7ffc6306c2ae3f07e69d5d4344f66e0f447233c (patch) | |
| tree | 90a2a2533646357109a47e7d35468ec1066f8af3 | |
| parent | 3d7155affc4760e6d3fb132da1e9f858238c5f02 (diff) | |
Set the initial index later in _tokenize().
Small optimization. No need to fetch it for 'help' tokens, which return
early.
| -rw-r--r-- | kconfiglib.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index b7120f7..3f7df94 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -621,9 +621,10 @@ class Config(object): return _Feed([]) if for_eval: - i = 0 # The current index in the string being tokenized previous = None # The previous token seen tokens = [] + i = 0 # The current index in the string being tokenized + else: # The initial word on a line is parsed specially. Let # command_chars = [A-Za-z0-9_]. Then @@ -631,13 +632,9 @@ class Config(object): # - the first token consists the following one or more # command_chars characters. # This is why things like "----help--" are accepted. - initial_token_match = _initial_token_re_match(s) if initial_token_match is None: return _Feed([]) - # The current index in the string being tokenized - i = initial_token_match.end() - keyword = _get_keyword(initial_token_match.group(1)) if keyword is None: # We expect a keyword as the first token @@ -646,8 +643,11 @@ class Config(object): # Avoid junk after "help", e.g. "---", being registered as a # symbol return _Feed([T_HELP]) - tokens = [keyword] + previous = keyword + tokens = [keyword] + # The current index in the string being tokenized + i = initial_token_match.end() # _tokenize() is a hotspot during parsing, and this speeds things up a # bit |
