diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-05-26 14:53:28 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-05-26 15:04:35 +0200 |
| commit | ab2431ca36139c6d450adfe275d1e14088633eed (patch) | |
| tree | 44ce625e8eea308d998770b100910e37ca3248e4 | |
| parent | bce7d706e5acd6cc86ad2b881e23b0382b74d667 (diff) | |
Micro-optimize _parse_help() loop
Shaves ~6% off the _parse_help() runtime for the x86 Kconfigs in
cProfile.
| -rw-r--r-- | kconfiglib.py | 3 | ||||
| -rw-r--r-- | tests/Klocation | 6 | ||||
| -rw-r--r-- | testsuite.py | 4 |
3 files changed, 10 insertions, 3 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index a1e3038..f032b26 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -2327,7 +2327,8 @@ class Kconfig(object): add_help_line(line.expandtabs()[indent:].rstrip()) line = readline() - self._linenr += 1 + + self._linenr += len(help_lines) node.help = "\n".join(help_lines).rstrip() + "\n" self._saved_line = line # "Unget" the line diff --git a/tests/Klocation b/tests/Klocation index 6438739..887e4a0 100644 --- a/tests/Klocation +++ b/tests/Klocation @@ -28,6 +28,12 @@ config HELP_2 baz +config HELP_3 + help + foo + bar + bool + config MULTI_DEF endif diff --git a/testsuite.py b/testsuite.py index 13793f1..1d79fa6 100644 --- a/testsuite.py +++ b/testsuite.py @@ -927,14 +927,14 @@ g verify_locations(c.syms["MULTI_DEF"].nodes, "tests/Klocation:7", - "tests/Klocation:31", + "tests/Klocation:37", "tests/Klocation_sourced:3", "tests/sub/Klocation_rsourced:2", "tests/sub/Klocation_gsourced1:1", "tests/sub/Klocation_gsourced2:1", "tests/sub/Klocation_grsourced1:1", "tests/sub/Klocation_grsourced2:1", - "tests/Klocation:54") + "tests/Klocation:60") verify_locations(c.named_choices["CHOICE"].nodes, "tests/Klocation_sourced:5") |
