From: Mika Lindqvist Date: Wed, 24 Jun 2015 22:01:00 +0000 (+0300) Subject: Use TRIGGER_LEVEL instead of hard-coded '6'. X-Git-Tag: 1.9.9-b1~763 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e3255ce2dfd3429cf604d5a5d7c0160a46c837e;p=thirdparty%2Fzlib-ng.git Use TRIGGER_LEVEL instead of hard-coded '6'. ** Only merged part of this commit, based on 9460967fcfde4d83574f82eabe2a2bc91a9c351a --- diff --git a/deflate.c b/deflate.c index 20a097074..739c21f25 100644 --- a/deflate.c +++ b/deflate.c @@ -131,7 +131,7 @@ static const config configuration_table[10] = { /* 6 */ {8, 16, 128, 128, deflate_slow}, #endif -/* 7 */ {8, 32, 128, 256, deflate_slow}, +/* 7 */ {8, 32, 128, 256, deflate_slow}, /* 8 */ {32, 128, 258, 1024, deflate_slow}, /* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ @@ -645,9 +645,9 @@ int ZEXPORT deflate(z_stream *strm, int flush) { if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) level_flags = 0; - else if (s->level < 6) + else if (s->level < TRIGGER_LEVEL) level_flags = 1; - else if (s->level == 6) + else if (s->level == TRIGGER_LEVEL) level_flags = 2; else level_flags = 3; diff --git a/deflate.h b/deflate.h index 475bb3104..f92c0d114 100644 --- a/deflate.h +++ b/deflate.h @@ -386,10 +386,17 @@ void ZLIB_INTERNAL bi_windup(deflate_state *s); * input characters, so that a running hash key can be computed from the * previous key instead of complete recalculation each time. */ + +#ifdef NOT_TWEAK_COMPILER +#define TRIGGER_LEVEL 6 +#else +#define TRIGGER_LEVEL 5 +#endif + #ifdef X86_SSE4_2_CRC_HASH #define UPDATE_HASH(s, h, i) \ do {\ - if (s->level < 6) \ + if (s->level < TRIGGER_LEVEL) \ h = (3483 * (s->window[i]) +\ 23081* (s->window[i+1]) +\ 6954 * (s->window[i+2]) +\ diff --git a/match.c b/match.c index 25b3b14ce..28ce47b4b 100644 --- a/match.c +++ b/match.c @@ -150,7 +150,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) { * is pretty low, so for performance it's best to * outright stop here for the lower compression levels */ - if (s->level < 6) + if (s->level < TRIGGER_LEVEL) break; } } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length); @@ -271,7 +271,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) { * is pretty low, so for performance it's best to * outright stop here for the lower compression levels */ - if (s->level < 6) + if (s->level < TRIGGER_LEVEL) break; } } while (--chain_length && (cur_match = prev[cur_match & wmask]) > limit); @@ -459,7 +459,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) { * is pretty low, so for performance it's best to * outright stop here for the lower compression levels */ - if (s->level < 6) + if (s->level < TRIGGER_LEVEL) break; } } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length != 0);