diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-04-25 09:54:02 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-04-25 10:50:50 -0400 |
commit | 4b01b45ec1a2d561eab8bf7d8934857268e48701 (patch) | |
tree | b8e193247fe1e7decf263bee8ad68e6f0a6133c2 /src/common | |
parent | 880fb3e3a9aba21c0b36aa4aa5659432e90eb827 (diff) | |
download | tor-4b01b45ec1a2d561eab8bf7d8934857268e48701.tar.gz tor-4b01b45ec1a2d561eab8bf7d8934857268e48701.zip |
Add a "best compression" flag.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/compress.c | 6 | ||||
-rw-r--r-- | src/common/compress.h | 4 | ||||
-rw-r--r-- | src/common/compress_lzma.c | 1 | ||||
-rw-r--r-- | src/common/compress_zlib.c | 4 | ||||
-rw-r--r-- | src/common/compress_zstd.c | 1 |
5 files changed, 10 insertions, 6 deletions
diff --git a/src/common/compress.c b/src/common/compress.c index 2729d9f78c..e8d11b9715 100644 --- a/src/common/compress.c +++ b/src/common/compress.c @@ -208,8 +208,8 @@ tor_compress(char **out, size_t *out_len, compress_method_t method) { return tor_compress_impl(1, out, out_len, in, in_len, method, - HIGH_COMPRESSION, - 1, LOG_WARN); // XXXX "best"? + BEST_COMPRESSION, + 1, LOG_WARN); } /** Given zero or more zlib-compressed or gzip-compressed strings of @@ -231,7 +231,7 @@ tor_uncompress(char **out, size_t *out_len, int protocol_warn_level) { return tor_compress_impl(0, out, out_len, in, in_len, method, - HIGH_COMPRESSION, + BEST_COMPRESSION, complete_only, protocol_warn_level); } diff --git a/src/common/compress.h b/src/common/compress.h index 2d812e4430..8be67df3a6 100644 --- a/src/common/compress.h +++ b/src/common/compress.h @@ -26,11 +26,11 @@ typedef enum { /** * Enumeration to define tradeoffs between memory usage and compression level. - * HIGH_COMPRESSION saves the most bandwidth; LOW_COMPRESSION saves the most + * BEST_COMPRESSION saves the most bandwidth; LOW_COMPRESSION saves the most * memory. **/ typedef enum { - HIGH_COMPRESSION, MEDIUM_COMPRESSION, LOW_COMPRESSION + BEST_COMPRESSION, HIGH_COMPRESSION, MEDIUM_COMPRESSION, LOW_COMPRESSION } compression_level_t; int tor_compress(char **out, size_t *out_len, diff --git a/src/common/compress_lzma.c b/src/common/compress_lzma.c index 9c61d587ee..59b7df6e0c 100644 --- a/src/common/compress_lzma.c +++ b/src/common/compress_lzma.c @@ -32,6 +32,7 @@ memory_level(compression_level_t level) { switch (level) { default: + case BEST_COMPRESSION: case HIGH_COMPRESSION: return 9; case MEDIUM_COMPRESSION: return 6; case LOW_COMPRESSION: return 3; diff --git a/src/common/compress_zlib.c b/src/common/compress_zlib.c index 37768ee49e..d8200d5d3d 100644 --- a/src/common/compress_zlib.c +++ b/src/common/compress_zlib.c @@ -56,6 +56,7 @@ memory_level(compression_level_t level) { switch (level) { default: + case BEST_COMPRESSION: return 9; case HIGH_COMPRESSION: return 8; case MEDIUM_COMPRESSION: return 7; case LOW_COMPRESSION: return 6; @@ -70,6 +71,7 @@ method_bits(compress_method_t method, compression_level_t level) const int flag = method == GZIP_METHOD ? 16 : 0; switch (level) { default: + case BEST_COMPRESSION: case HIGH_COMPRESSION: return flag + 15; case MEDIUM_COMPRESSION: return flag + 13; case LOW_COMPRESSION: return flag + 11; @@ -162,7 +164,7 @@ tor_zlib_compress_new(int compress_, if (! compress_) { /* use this setting for decompression, since we might have the * max number of window bits */ - compression_level = HIGH_COMPRESSION; + compression_level = BEST_COMPRESSION; } out = tor_malloc_zero(sizeof(tor_zlib_compress_state_t)); diff --git a/src/common/compress_zstd.c b/src/common/compress_zstd.c index 76f2991e3d..58fa327571 100644 --- a/src/common/compress_zstd.c +++ b/src/common/compress_zstd.c @@ -33,6 +33,7 @@ memory_level(compression_level_t level) { switch (level) { default: + case BEST_COMPRESSION: case HIGH_COMPRESSION: return 9; case MEDIUM_COMPRESSION: return 8; case LOW_COMPRESSION: return 7; |