From 4a00586bdaf885c73bc8e735b59dad48889435fd Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Thu, 4 Jun 2015 18:28:53 +0200 Subject: Refactor _get_lines(). Also improves performance. A yield-based implementation would be interesting to experiment with, to see if I/O + computation interleaving helps here. --- kconfiglib.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'kconfiglib.py') diff --git a/kconfiglib.py b/kconfiglib.py index 9b1bbca..1b4ac3d 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -3731,18 +3731,13 @@ def _get_lines(filename): with open(filename, "r") as f: lines = [] accum = "" - while 1: - line = f.readline() - - if line == "": - return lines - + for line in f: if line.endswith("\\\n"): accum += line[:-2] else: - accum += line - lines.append(accum) + lines.append(accum + line) accum = "" + return lines def _strip_trailing_slash(path): """Removes any trailing slash from 'path'.""" -- cgit v1.2.3