]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Use TRIGGER_LEVEL instead of hard-coded '6'.
authorMika Lindqvist <postmaster@raasu.org>
Wed, 24 Jun 2015 22:01:00 +0000 (01:01 +0300)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Mon, 30 Jan 2017 10:08:14 +0000 (11:08 +0100)
** Only merged part of this commit, based on 9460967fcfde4d83574f82eabe2a2bc91a9c351a

deflate.c
deflate.h
match.c

index 20a09707475fd4548bb1ba3fcaf2f06c87b5bbfc..739c21f25fa8b6f0a726ab1f036acac338a8452b 100644 (file)
--- 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;
index 475bb3104fc5a40dbc3c8fe7032952fd17661a01..f92c0d11466c0981f49ce7d7967d46d815a87475 100644 (file)
--- 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 25b3b14ce074e94861d3862910cafc5abcabaa70..28ce47b4b94b2b60c6e8cb4b65a89a622f4acafd 100644 (file)
--- 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);