reads were being rounded up to an 8k buffer size, even with no buffering specified when the file was opened. i traced this back to the old ChannelFile where it worked correctly. fix to only buffer when asked to.
This commit is contained in:
parent
284614a857
commit
bbcf7687aa
|
@ -147,8 +147,11 @@ class BufferedFile (object):
|
||||||
self._pos += len(result)
|
self._pos += len(result)
|
||||||
return result
|
return result
|
||||||
while len(self._rbuffer) < size:
|
while len(self._rbuffer) < size:
|
||||||
|
read_size = size - len(self._rbuffer)
|
||||||
|
if self._flags & _FLAG_BUFFERED:
|
||||||
|
read_size = max(self._bufsize, read_size)
|
||||||
try:
|
try:
|
||||||
new_data = self._read(max(self._bufsize, size - len(self._rbuffer)))
|
new_data = self._read(read_size)
|
||||||
except EOFError:
|
except EOFError:
|
||||||
new_data = None
|
new_data = None
|
||||||
if (new_data is None) or (len(new_data) == 0):
|
if (new_data is None) or (len(new_data) == 0):
|
||||||
|
@ -205,7 +208,7 @@ class BufferedFile (object):
|
||||||
return line
|
return line
|
||||||
n = size - len(line)
|
n = size - len(line)
|
||||||
else:
|
else:
|
||||||
n = self._DEFAULT_BUFSIZE
|
n = self._bufsize
|
||||||
if ('\n' in line) or ((self._flags & _FLAG_UNIVERSAL_NEWLINE) and ('\r' in line)):
|
if ('\n' in line) or ((self._flags & _FLAG_UNIVERSAL_NEWLINE) and ('\r' in line)):
|
||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue