mirror of
https://github.com/python/cpython.git
synced 2024-11-24 10:24:35 +08:00
On behalf of Nadeem Vawda: issue #10376: micro-optimize reading from a Zipfile.
(patch by Serhiy)
This commit is contained in:
parent
3861d8b271
commit
78157b3f6f
@ -733,12 +733,13 @@ class ZipExtFile(io.BufferedIOBase):
|
||||
buf += self._read1(self.MAX_N)
|
||||
return buf
|
||||
|
||||
n -= len(self._readbuffer) - self._offset
|
||||
if n < 0:
|
||||
buf = self._readbuffer[self._offset:n]
|
||||
self._offset += len(buf)
|
||||
end = n + self._offset
|
||||
if end < len(self._readbuffer):
|
||||
buf = self._readbuffer[self._offset:end]
|
||||
self._offset = end
|
||||
return buf
|
||||
|
||||
n = end - len(self._readbuffer)
|
||||
buf = self._readbuffer[self._offset:]
|
||||
self._readbuffer = b''
|
||||
self._offset = 0
|
||||
@ -774,12 +775,13 @@ class ZipExtFile(io.BufferedIOBase):
|
||||
buf += data
|
||||
return buf
|
||||
|
||||
n -= len(self._readbuffer) - self._offset
|
||||
if n < 0:
|
||||
buf = self._readbuffer[self._offset:n]
|
||||
self._offset += len(buf)
|
||||
end = n + self._offset
|
||||
if end < len(self._readbuffer):
|
||||
buf = self._readbuffer[self._offset:end]
|
||||
self._offset = end
|
||||
return buf
|
||||
|
||||
n = end - len(self._readbuffer)
|
||||
buf = self._readbuffer[self._offset:]
|
||||
self._readbuffer = b''
|
||||
self._offset = 0
|
||||
|
Loading…
Reference in New Issue
Block a user