]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Removed TRIGGER_LEVEL byte masking from INSERT_STRING and UPDATE_HASH due to poor...
authorNathan Moinvaziri <nathan@nathanm.com>
Tue, 21 Apr 2020 17:29:37 +0000 (10:29 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 30 Apr 2020 08:01:46 +0000 (10:01 +0200)
From commit d306c75d3bb36cba73aec9b3b3ca378e31d1799e:

.. we hash 4 bytes, instead of 3, for certain levels. This shortens the hash chains, and also improves the quality
of each hash entry.

insert_string.c
insert_string_tpl.h

index 4e4c628bfbf5cd608aa619319d095ee16fa71871..e9efd517f88709065ecbd14f686e9315573f40ae 100644 (file)
 
 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86)
 #  define UPDATE_HASH(s, h, val) \
-    do {\
-        if (s->level < TRIGGER_LEVEL)\
-            h = (3483 * ((val) & 0xff) +\
-                 23081* (((val) >> 8) & 0xff) +\
-                 6954 * (((val) >> 16) & 0xff) +\
-                 20947* (((val) >> 24) & 0xff));\
-        else\
-            h = (25881* (((val)) & 0xff) +\
-                 24674* (((val) >> 8) & 0xff) +\
-                 25811* (((val) >> 16) & 0xff));\
-    } while (0)
+    h = (3483  * ((val) & 0xff) +\
+         23081 * (((val) >> 8) & 0xff) +\
+         6954  * (((val) >> 16) & 0xff) +\
+         20947 * (((val) >> 24) & 0xff));
 #else
 #  define UPDATE_HASH(s, h, val)\
     h = (s->ins_h = ((s->ins_h << s->hash_shift) ^ ((val) >> ((MIN_MATCH - 1) * 8))) & s->hash_mask)
index 0e90c3b00d0ef3701a2c928e5d41ee5c20941b73..c80c9f8ba03c9e19553f78bfbc2013e31d2389c6 100644 (file)
@@ -41,9 +41,6 @@ ZLIB_INTERNAL Pos QUICK_INSERT_STRING(deflate_state *const s, const Pos str) {
     val |= ((uint32_t)s->window[str+3] << 24);
 #endif
 
-    if (s->level >= TRIGGER_LEVEL)
-        val &= 0xFFFFFF;
-
     UPDATE_HASH(s, h, val);
     hm = h & s->hash_mask;
 
@@ -87,9 +84,6 @@ ZLIB_INTERNAL Pos INSERT_STRING(deflate_state *const s, const Pos str, unsigned
         val |= ((uint32_t)(strstart[3]) << 24);
 #endif
 
-        if (s->level >= TRIGGER_LEVEL)
-            val &= 0xFFFFFF;
-
         UPDATE_HASH(s, h, val);
         hm = h & s->hash_mask;