aboutsummaryrefslogtreecommitdiff
path: root/c/enc/hash_longest_match64_inc.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/enc/hash_longest_match64_inc.h')
-rw-r--r--c/enc/hash_longest_match64_inc.h14
1 files changed, 4 insertions, 10 deletions
diff --git a/c/enc/hash_longest_match64_inc.h b/c/enc/hash_longest_match64_inc.h
index d02435e..da75949 100644
--- a/c/enc/hash_longest_match64_inc.h
+++ b/c/enc/hash_longest_match64_inc.h
@@ -21,8 +21,8 @@ static BROTLI_INLINE size_t FN(StoreLookahead)(void) { return 8; }
/* HashBytes is the function that chooses the bucket to place the address in. */
static BROTLI_INLINE uint32_t FN(HashBytes)(const uint8_t* BROTLI_RESTRICT data,
- const uint64_t mask,
const int shift) {
+ const uint64_t mask = (~((uint64_t)0U)) >> 24; /* Use only 5 bytes. */
const uint64_t h = (BROTLI_UNALIGNED_LOAD64LE(data) & mask) * kHashMul64Long;
/* The higher bits contain more mixture from the multiplication,
so we take our results from there. */
@@ -37,8 +37,6 @@ typedef struct HashLongestMatch {
size_t block_size_;
/* Left-shift for computing hash bucket index from hash value. */
int hash_shift_;
- /* Mask for selecting the next 4-8 bytes of input */
- uint64_t hash_mask_;
/* Mask for accessing entries in a block (in a ring-buffer manner). */
uint32_t block_mask_;
@@ -64,7 +62,6 @@ static void FN(Initialize)(
BROTLI_UNUSED(params);
self->hash_shift_ = 64 - common->params.bucket_bits;
- self->hash_mask_ = (~((uint64_t)0U)) >> (64 - 8 * common->params.hash_len);
self->bucket_size_ = (size_t)1 << common->params.bucket_bits;
self->block_bits_ = common->params.block_bits;
self->block_size_ = (size_t)1 << common->params.block_bits;
@@ -84,8 +81,7 @@ static void FN(Prepare)(
if (one_shot && input_size <= partial_prepare_threshold) {
size_t i;
for (i = 0; i < input_size; ++i) {
- const uint32_t key = FN(HashBytes)(&data[i], self->hash_mask_,
- self->hash_shift_);
+ const uint32_t key = FN(HashBytes)(&data[i], self->hash_shift_);
num[key] = 0;
}
} else {
@@ -111,8 +107,7 @@ static BROTLI_INLINE void FN(Store)(
const size_t mask, const size_t ix) {
uint16_t* BROTLI_RESTRICT num = self->num_;
uint32_t* BROTLI_RESTRICT buckets = self->buckets_;
- const uint32_t key = FN(HashBytes)(&data[ix & mask], self->hash_mask_,
- self->hash_shift_);
+ const uint32_t key = FN(HashBytes)(&data[ix & mask], self->hash_shift_);
const size_t minor_ix = num[key] & self->block_mask_;
const size_t offset = minor_ix + (key << self->block_bits_);
++num[key];
@@ -217,8 +212,7 @@ static BROTLI_INLINE void FN(FindLongestMatch)(
}
}
{
- const uint32_t key = FN(HashBytes)(
- &data[cur_ix_masked], self->hash_mask_, self->hash_shift_);
+ const uint32_t key = FN(HashBytes)(&data[cur_ix_masked], self->hash_shift_);
uint32_t* BROTLI_RESTRICT bucket = &buckets[key << self->block_bits_];
const size_t down =
(num[key] > self->block_size_) ?