From c7fb8d94c5ec8fb6433cc3458aed17bf96b410ad Mon Sep 17 00:00:00 2001 From: CrescentApricot Date: Mon, 4 Mar 2019 23:26:20 +0900 Subject: [PATCH] :pencil: small improve --- lz4unipy/handler.py | 10 +++------- setup.py | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lz4unipy/handler.py b/lz4unipy/handler.py index 8eb9891..b6b167f 100644 --- a/lz4unipy/handler.py +++ b/lz4unipy/handler.py @@ -8,20 +8,16 @@ def compress(data: bytes) -> bytes: buf = lz4.block.compress(data, mode="high_compression")[4:] with BytesIO() as bio: - bio.write(pack('i', 100)) + bio.write(b'd\x00\x00\x00') bio.write(pack('i', len(data))) bio.write(pack('i', len(buf))) - bio.write(pack('i', 1)) + bio.write(b'\x01\x00\x00\x00') bio.write(buf) return bio.getvalue() def decompress(data: bytes) -> bytes: - with BytesIO() as bio: - bio.write(data[4:8]) - bio.write(data[16:]) - stream = bio.getvalue() - return lz4.block.decompress(stream) + return lz4.block.decompress(data[16:], uncompressed_size=unpack("i", data[4:8])[0]) def is_compressed(data: bytes) -> bool: diff --git a/setup.py b/setup.py index 8c4db2c..d6aead8 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='lz4unipy', - version='2.0.0', + version='2.0.1', description='unity3d compatible lz4 (un)compress tool working on Python3.', long_description=long_description, author='CrescentApricot',