summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-12-15 12:43:55 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2018-12-15 12:43:55 +0100
commit3316fb3d9f37fcae12c5ef5abe008daa772202c1 (patch)
tree5378b03d78a4c4d9391c71b24206e23c93e7c19d
parente34eb67a736c765cd1f858de80ff50157eda18bc (diff)
Tighten up _next_line()
self._line is only used for error reporting, and the empty string returned at EOF would never be shown. Move the assignment to after readline() and use a local variable to hold the line instead, to get rid of some property lookups.
-rw-r--r--kconfiglib.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index b9264e4..e29de4d 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -1884,17 +1884,18 @@ class Kconfig(object):
# Note: readline() returns '' over and over at EOF, which we rely on
# for help texts at the end of files (see _line_after_help())
- self._line = self._file.readline()
- if not self._line:
+ line = self._file.readline()
+ if not line:
return False
self._linenr += 1
# Handle line joining
- while self._line.endswith("\\\n"):
- self._line = self._line[:-2] + self._file.readline()
+ while line.endswith("\\\n"):
+ line = line[:-2] + self._file.readline()
self._linenr += 1
- self._tokens = self._tokenize(self._line)
+ self._line = line # Used for error reporting
+ self._tokens = self._tokenize(line)
# Initialize to 1 instead of 0 to factor out code from _parse_block()
# and _parse_properties(). They immediately fetch self._tokens[0].
self._tokens_i = 1