comparison mercurial/util.py @ 37496:1765ed63db40

util: drop write_content_size=True This is now the default in python-zstandard 0.9. While we're here, also add a comment about the ability to drop frame magic to save space. Differential Revision: https://phab.mercurial-scm.org/D3199
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 09 Apr 2018 10:18:10 -0700
parents 9ecb7c471cfb
children 5b8a260769a2
comparison
equal deleted inserted replaced
37495:b1fb341d8a61 37496:1765ed63db40
3564 dctx = zstd.ZstdDecompressor() 3564 dctx = zstd.ZstdDecompressor()
3565 return chunkbuffer(dctx.read_from(fh)) 3565 return chunkbuffer(dctx.read_from(fh))
3566 3566
3567 class zstdrevlogcompressor(object): 3567 class zstdrevlogcompressor(object):
3568 def __init__(self, zstd, level=3): 3568 def __init__(self, zstd, level=3):
3569 # Writing the content size adds a few bytes to the output. However, 3569 # TODO consider omitting frame magic to save 4 bytes.
3570 # it allows decompression to be more optimal since we can 3570 # This writes content sizes into the frame header. That is
3571 # pre-allocate a buffer to hold the result. 3571 # extra storage. But it allows a correct size memory allocation
3572 self._cctx = zstd.ZstdCompressor(level=level, 3572 # to hold the result.
3573 write_content_size=True) 3573 self._cctx = zstd.ZstdCompressor(level=level)
3574 self._dctx = zstd.ZstdDecompressor() 3574 self._dctx = zstd.ZstdDecompressor()
3575 self._compinsize = zstd.COMPRESSION_RECOMMENDED_INPUT_SIZE 3575 self._compinsize = zstd.COMPRESSION_RECOMMENDED_INPUT_SIZE
3576 self._decompinsize = zstd.DECOMPRESSION_RECOMMENDED_INPUT_SIZE 3576 self._decompinsize = zstd.DECOMPRESSION_RECOMMENDED_INPUT_SIZE
3577 3577
3578 def compress(self, data): 3578 def compress(self, data):