diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-05-18 00:02:33 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-05-18 00:03:36 +0200 |
| commit | 39bc30fbc37cd6e4dc6dc6f747ae4e76bdb12094 (patch) | |
| tree | 96bf052e8732e5b9a108795c3df73af3380d534c /kconfiglib.py | |
| parent | 9ba9db78b2d3d0cf1c24e6e0929f5850940234dd (diff) | |
Refactor help text parsing loop
This is less twisty, and generates slightly smaller bytecode. Probably
doesn't help to special-case the first line.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index f3624c4..9c2e614 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -2288,20 +2288,17 @@ class Kconfig(object): self._saved_line = line # "Unget" the line return - help_lines = [_dedent_rstrip(line, indent)] + # The help text goes on till the first non-empty line with less indent + # than the first line + + help_lines = [] # Small optimization add_help_line = help_lines.append - # The help text goes on till the first non-empty line with less indent - - while 1: + while line and (line.isspace() or _indentation(line) >= indent): + add_help_line(_dedent_rstrip(line, indent)) line = readline() self._linenr += 1 - if not (line and (line.isspace() or \ - _indentation(line) >= indent)): - break - - add_help_line(_dedent_rstrip(line, indent)) node.help = "\n".join(help_lines).rstrip() + "\n" self._saved_line = line # "Unget" the line |
