Skip to content

Commit c0d6a51

Browse files
committed
Use more code from gzip
1 parent 82916dc commit c0d6a51

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/isal/igzip.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,24 +206,13 @@ class _IGzipReader(gzip._GzipReader):
206206
def __init__(self, fp):
207207
super().__init__(fp)
208208
self._decomp_factory = isal_zlib.decompressobj
209-
self._decomp_args = dict(wbits=64+isal_zlib.MAX_WBITS)
210-
# Set wbits such that ISAL_GZIP_NO_HDR_VER is used. This means that
211-
# it does not read a header, and it verifies the trailer.
212209
self._decompressor = self._decomp_factory(**self._decomp_args)
213210

214211
def _add_read_data(self, data):
215-
# isa-l verifies the trailer data, so no need to keep track of the crc.
216-
self._stream_size = self._stream_size + len(data)
217-
218-
def _read_eof(self):
219-
# Gzip files can be padded with zeroes and still have archives.
220-
# Consume all zero bytes and set the file position to the first
221-
# non-zero byte. See http://www.gzip.org/#faq8
222-
c = b"\x00"
223-
while c == b"\x00":
224-
c = self._fp.read(1)
225-
if c:
226-
self._fp.prepend(c)
212+
# Use faster isal crc32 calculation and update the stream size in place
213+
# compared to CPython gzip
214+
self._crc = isal_zlib.crc32(data, self._crc)
215+
self._stream_size += len(data)
227216

228217

229218
# Plagiarized from gzip.py from python's stdlib.

0 commit comments

Comments
 (0)