bake in runtime constant PiperOrigin-RevId: 548977179
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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } } { - 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_) ?
diff --git a/c/enc/params.h b/c/enc/params.h index baeb319..78b2ab6 100644 --- a/c/enc/params.h +++ b/c/enc/params.h
@@ -17,7 +17,6 @@ int type; int bucket_bits; int block_bits; - int hash_len; int num_last_distances_to_check; } BrotliHasherParams;
diff --git a/c/enc/quality.h b/c/enc/quality.h index 99891b4..4415a54 100644 --- a/c/enc/quality.h +++ b/c/enc/quality.h
@@ -133,7 +133,6 @@ hparams->type = 6; hparams->block_bits = params->quality - 1; hparams->bucket_bits = 15; - hparams->hash_len = 5; hparams->num_last_distances_to_check = params->quality < 7 ? 4 : params->quality < 9 ? 10 : 16; } else {