From ab2431ca36139c6d450adfe275d1e14088633eed Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sat, 26 May 2018 14:53:28 +0200 Subject: Micro-optimize _parse_help() loop Shaves ~6% off the _parse_help() runtime for the x86 Kconfigs in cProfile. --- kconfiglib.py | 3 ++- tests/Klocation | 6 ++++++ 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") -- cgit v1.2.3