diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2015-06-04 18:28:53 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2015-06-04 18:28:53 +0200 |
| commit | 4a00586bdaf885c73bc8e735b59dad48889435fd (patch) | |
| tree | f106570f79e74d81ad9f8c13758e11f37410e105 | |
| parent | c48954d6d2a78d63bea8104f79e05f3f18723c47 (diff) | |
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.
| -rw-r--r-- | kconfiglib.py | 11 |
1 files changed, 3 insertions, 8 deletions
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'.""" |
