summaryrefslogtreecommitdiff
path: root/insert_string_roll.c
diff options
context:
space:
mode:
authorNathan Moinvaziri <nathan@nathanm.com>2021-06-10 17:25:27 -0700
committerHans Kristian Rosbach <hk-github@circlestorm.org>2021-06-25 20:09:14 +0200
commit694878996926ba75373d62c9a8011c1b01a1cb0b (patch)
tree9588ca512ea430d3c22990df8eb090905abdd044 /insert_string_roll.c
parentc0cca0854206e25b41f1ee403dfb9a522ba85328 (diff)
downloadProject-Tick-694878996926ba75373d62c9a8011c1b01a1cb0b.tar.gz
Project-Tick-694878996926ba75373d62c9a8011c1b01a1cb0b.zip
Added rolling hash functions for hash table.
Diffstat (limited to 'insert_string_roll.c')
-rw-r--r--insert_string_roll.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/insert_string_roll.c b/insert_string_roll.c
new file mode 100644
index 0000000000..dfea347bcc
--- /dev/null
+++ b/insert_string_roll.c
@@ -0,0 +1,24 @@
+/* insert_string_roll.c -- insert_string rolling hash variant
+ *
+ * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ *
+ */
+
+#include "zbuild.h"
+#include "deflate.h"
+
+#define HASH_SLIDE 5
+
+#define HASH_CALC(s, h, val) h = ((h << HASH_SLIDE) ^ ((uint8_t)val))
+#define HASH_CALC_VAR s->ins_h
+#define HASH_CALC_VAR_INIT
+#define HASH_CALC_READ val = strstart[0]
+#define HASH_CALC_MASK (32768u - 1u)
+#define HASH_CALC_OFFSET (STD_MIN_MATCH-1)
+
+#define UPDATE_HASH update_hash_roll
+#define INSERT_STRING insert_string_roll
+#define QUICK_INSERT_STRING quick_insert_string_roll
+
+#include "insert_string_tpl.h"