]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Increase hash table size from 15 to 16 bits.
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Fri, 21 Aug 2020 14:17:55 +0000 (16:17 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sun, 23 Aug 2020 07:57:45 +0000 (09:57 +0200)
This gives a good performance increase, and usually also improves compression.
Make separate define HASH_SLIDE for fallback version of UPDATE_HASH.

deflate.h
insert_string.c

index f9db02bbdf8ccf8600b47d36bc31efe07678e85b..ef84bde03a6dcbe2947f4923ad5e21066f0b8635 100644 (file)
--- a/deflate.h
+++ b/deflate.h
@@ -68,9 +68,9 @@
 #define FINISH_STATE 666    /* stream complete */
 /* Stream status */
 
-#define HASH_BITS 15        /* log2(HASH_SIZE) */
-#define HASH_SIZE 32768     /* number of elements in hash table */
-#define HASH_MASK 0x7FFF    /* HASH_SIZE-1 */
+#define HASH_BITS    16u           /* log2(HASH_SIZE) */
+#define HASH_SIZE 65536u           /* number of elements in hash table */
+#define HASH_MASK (HASH_SIZE - 1u) /* HASH_SIZE-1 */
 
 
 /* Data structure describing a single value and its code string. */
index 7233668143d1217bf654ee4299a21fbf463396ee..4ddf9ae5dbd3edd36c070f60bceb70949eb248d7 100644 (file)
  *    input characters, so that a running hash key can be computed from the
  *    previous key instead of complete recalculation each time.
  */
+#define HASH_SLIDE 16  // Number of bits to slide hash
+
 #define UPDATE_HASH(s, h, val) \
-    h = ((val * 2654435761U) >> (32 - HASH_BITS));
+    h = ((val * 2654435761U) >> HASH_SLIDE);
 
 #define INSERT_STRING       insert_string_c
 #define QUICK_INSERT_STRING quick_insert_string_c