Kaydet (Commit) 78157b3f authored tarafından Antoine Pitrou's avatar Antoine Pitrou

On behalf of Nadeem Vawda: issue #10376: micro-optimize reading from a Zipfile.

(patch by Serhiy)
üst 3861d8b2
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment