Skip to content

Commit

Permalink
For effiency, set newline character outside of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Feb 15, 2020
1 parent cb298e3 commit e8f347f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/PIL/ContainerIO.py
Expand Up @@ -93,12 +93,13 @@ def readline(self):
:returns: An 8-bit string.
"""
s = b"" if "b" in self.fh.mode else ""
newline_character = b"\n" if "b" in self.fh.mode else "\n"
while True:
c = self.read(1)
if not c:
break
s = s + c
if c == (b"\n" if "b" in self.fh.mode else "\n"):
if c == newline_character:
break
return s

Expand Down

0 comments on commit e8f347f

Please sign in to comment.