From 3316fb3d9f37fcae12c5ef5abe008daa772202c1 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sat, 15 Dec 2018 12:43:55 +0100 Subject: 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. --- kconfiglib.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'kconfiglib.py') 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 -- cgit v1.2.3