Show More
@@ -456,6 +456,10 b' class _zlibengine(compressionengine):' | |||||
456 | return _GzipCompressedStreamReader(fh) |
|
456 | return _GzipCompressedStreamReader(fh) | |
457 |
|
457 | |||
458 | class zlibrevlogcompressor(object): |
|
458 | class zlibrevlogcompressor(object): | |
|
459 | ||||
|
460 | def __init__(self, level=None): | |||
|
461 | self._level = level | |||
|
462 | ||||
459 | def compress(self, data): |
|
463 | def compress(self, data): | |
460 | insize = len(data) |
|
464 | insize = len(data) | |
461 | # Caller handles empty input case. |
|
465 | # Caller handles empty input case. | |
@@ -465,7 +469,10 b' class _zlibengine(compressionengine):' | |||||
465 | return None |
|
469 | return None | |
466 |
|
470 | |||
467 | elif insize <= 1000000: |
|
471 | elif insize <= 1000000: | |
|
472 | if self._level is None: | |||
468 | compressed = zlib.compress(data) |
|
473 | compressed = zlib.compress(data) | |
|
474 | else: | |||
|
475 | compressed = zlib.compress(data, self._level) | |||
469 | if len(compressed) < insize: |
|
476 | if len(compressed) < insize: | |
470 | return compressed |
|
477 | return compressed | |
471 | return None |
|
478 | return None | |
@@ -474,7 +481,10 b' class _zlibengine(compressionengine):' | |||||
474 | # memory usage for large inputs. So do streaming compression |
|
481 | # memory usage for large inputs. So do streaming compression | |
475 | # on large inputs. |
|
482 | # on large inputs. | |
476 | else: |
|
483 | else: | |
|
484 | if self._level is None: | |||
477 | z = zlib.compressobj() |
|
485 | z = zlib.compressobj() | |
|
486 | else: | |||
|
487 | z = zlib.compressobj(level=self._level) | |||
478 | parts = [] |
|
488 | parts = [] | |
479 | pos = 0 |
|
489 | pos = 0 | |
480 | while pos < insize: |
|
490 | while pos < insize: |
General Comments 0
You need to be logged in to leave comments.
Login now