diff options
| author | Nathan Moinvaziri <nathan@nathanm.com> | 2021-06-10 17:25:27 -0700 |
|---|---|---|
| committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2021-06-25 20:09:14 +0200 |
| commit | 694878996926ba75373d62c9a8011c1b01a1cb0b (patch) | |
| tree | 9588ca512ea430d3c22990df8eb090905abdd044 /insert_string.c | |
| parent | c0cca0854206e25b41f1ee403dfb9a522ba85328 (diff) | |
| download | Project-Tick-694878996926ba75373d62c9a8011c1b01a1cb0b.tar.gz Project-Tick-694878996926ba75373d62c9a8011c1b01a1cb0b.zip | |
Added rolling hash functions for hash table.
Diffstat (limited to 'insert_string.c')
| -rw-r--r-- | insert_string.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/insert_string.c b/insert_string.c index 4ddf9ae5db..cfe39837f8 100644 --- a/insert_string.c +++ b/insert_string.c @@ -1,4 +1,4 @@ -/* insert_string_c -- insert_string variant for c +/* insert_string.c -- insert_string integer hash variant * * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h @@ -8,18 +8,14 @@ #include "zbuild.h" #include "deflate.h" -/* =========================================================================== - * 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. - */ -#define HASH_SLIDE 16 // Number of bits to slide hash +#define HASH_SLIDE 16 -#define UPDATE_HASH(s, h, val) \ - h = ((val * 2654435761U) >> HASH_SLIDE); +#define HASH_CALC(s, h, val) h = ((val * 2654435761U) >> HASH_SLIDE); +#define HASH_CALC_VAR h +#define HASH_CALC_VAR_INIT uint32_t h = 0 -#define INSERT_STRING insert_string_c -#define QUICK_INSERT_STRING quick_insert_string_c +#define UPDATE_HASH update_hash_c +#define INSERT_STRING insert_string_c +#define QUICK_INSERT_STRING quick_insert_string_c #include "insert_string_tpl.h" |
