correctly calculate compression ratio, taking header size into account, too

This commit is contained in:
Elmar Hoffmann 2020-04-03 17:21:11 +02:00
parent cd1f2b11be
commit 54ab8cd917
1 changed files with 2 additions and 1 deletions

View File

@ -311,7 +311,8 @@ class Auto(CompressorBase):
*lz4_data* is the LZ4 result if *compressor* is LZ4 as well, otherwise it is None.
"""
lz4_data = LZ4_COMPRESSOR.compress(data)
ratio = len(lz4_data) / len(data)
# lz4_data includes the compression type header, while data does not yet
ratio = len(lz4_data) / (len(data) + 2)
if ratio < 0.97:
return self.compressor, lz4_data
elif ratio < 1: