summaryrefslogtreecommitdiff
path: root/kconfiglib.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-01-20 06:22:37 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2018-01-20 06:22:37 +0100
commitf0a87cc0cdf02dbaa733352b052021a48fa42240 (patch)
treebc71e72811a1fc14b5bbdd4ee10845cf7bde71de /kconfiglib.py
parent707204ac4a5539c9b4d4875d12fec340ba95c1a2 (diff)
Micro-optimize _T_HELP parsing
Shaves a few % more from _parse_properties().
Diffstat (limited to 'kconfiglib.py')
-rw-r--r--kconfiglib.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index 9c5607e..99007a9 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -1720,8 +1720,11 @@ class Kconfig(object):
# Find first non-blank (not all-space) line and get its
# indentation
+ # Small optimization. This code is pretty hot.
+ readline = self._file.readline
+
while 1:
- line = self._file.readline()
+ line = readline()
self._linenr += 1
if not line or not line.isspace():
break
@@ -1739,18 +1742,20 @@ class Kconfig(object):
break
help_lines = [_dedent_rstrip(line, indent)]
+ # Small optimization
+ add_help_line = help_lines.append
# The help text goes on till the first non-empty line with less
# indent
while 1:
- line = self._file.readline()
+ line = readline()
self._linenr += 1
if not (line and (line.isspace() or \
_indentation(line) >= indent)):
break
- help_lines.append(_dedent_rstrip(line, indent))
+ add_help_line(_dedent_rstrip(line, indent))
node.help = "\n".join(help_lines).rstrip() + "\n"