summaryrefslogtreecommitdiff
path: root/insert_string_tpl.h
diff options
context:
space:
mode:
authorNathan Moinvaziri <nathan@nathanm.com>2021-06-14 17:27:37 -0700
committerHans Kristian Rosbach <hk-github@circlestorm.org>2021-06-25 20:09:14 +0200
commit5998d5b63211784bd8e44b2ba80ee63d2643f65c (patch)
tree734d8a6c9b0d54793f8e11c54e8669016b7b50b5 /insert_string_tpl.h
parent694878996926ba75373d62c9a8011c1b01a1cb0b (diff)
downloadProject-Tick-5998d5b63211784bd8e44b2ba80ee63d2643f65c.tar.gz
Project-Tick-5998d5b63211784bd8e44b2ba80ee63d2643f65c.zip
Added update_hash to build hash incrementally.
Diffstat (limited to 'insert_string_tpl.h')
-rw-r--r--insert_string_tpl.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/insert_string_tpl.h b/insert_string_tpl.h
index e2c840bb2d..c116544f9d 100644
--- a/insert_string_tpl.h
+++ b/insert_string_tpl.h
@@ -42,6 +42,18 @@
#endif
/* ===========================================================================
+ * Update a hash value with the given input byte
+ * IN assertion: all calls to to UPDATE_HASH are made with consecutive
+ * input characters, so that a running hash key can be computed from the
+ * previous key instead of complete recalculation each time.
+ */
+Z_INTERNAL uint32_t UPDATE_HASH(deflate_state *const s, uint32_t h, uint32_t val) {
+ (void)s;
+ HASH_CALC(s, h, val);
+ return h & HASH_CALC_MASK;
+}
+
+/* ===========================================================================
* Quick insert string str in the dictionary and set match_head to the previous head
* of the hash chain (the most recent string with same hash key). Return
* the previous length of the hash chain.