Skip to content

Commit

Permalink
make sure all computations are the same across 64 and 32 bit builds
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrh committed Oct 31, 2018
1 parent 4fb327c commit df3236a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/bin/integration_tests.rs
Expand Up @@ -424,7 +424,7 @@ fn test_random_then_unicode_9_5() {
}

#[test]
fn test_random_then_unicode_9_5x() {
fn test_random_then_unicode_9x5() {
let c_size = roundtrip_helper(RANDOM_THEN_UNICODE, 11, 22, true);
assert_eq!(c_size, random_then_unicode_compressed_size_9_5x);
}
Expand Down
7 changes: 3 additions & 4 deletions src/enc/backward_references.rs
Expand Up @@ -37,7 +37,6 @@ pub enum BrotliEncoderMode {
BROTLI_FORCE_SIGNED_PRIOR = 6,
}


#[derive(Clone,Copy, Debug)]
pub struct BrotliHasherParams {
// type of hasher to use (default: type 6, but others have tradeoffs of speed/memory)
Expand Down Expand Up @@ -1177,14 +1176,14 @@ fn unopt_ctzll(mut val: usize) -> u8 {
fn BackwardReferenceScoreUsingLastDistance(copy_length: usize, h9_opts: H9Opts) -> u64 {
((h9_opts.literal_byte_score as u64) >> 2)
.wrapping_mul(copy_length as u64)
.wrapping_add((30u64 * 8u64).wrapping_mul(::core::mem::size_of::<usize>() as u64))
.wrapping_add((30u64 * 8u64).wrapping_mul(::core::mem::size_of::<u64>() as u64))
.wrapping_add(15u64)
}


fn BackwardReferenceScore(copy_length: usize, backward_reference_offset: usize, h9_opts: H9Opts) -> u64 {
(30u64 * 8u64)
.wrapping_mul(::core::mem::size_of::<usize>() as u64)
.wrapping_mul(::core::mem::size_of::<u64>() as u64)
.wrapping_add(((h9_opts.literal_byte_score as usize) >> 2).wrapping_mul(copy_length) as u64)
.wrapping_sub((30u64).wrapping_mul(Log2FloorNonZero(backward_reference_offset as u64) as u64))
}
Expand Down Expand Up @@ -1480,7 +1479,7 @@ fn CreateBackwardReferences<AH: AnyHasher>(dictionary: Option<&BrotliDictionary>
let random_heuristics_window_size: usize = LiteralSpreeLengthForSparseSearch(params);
let mut apply_random_heuristics: usize = position.wrapping_add(random_heuristics_window_size);
let kMinScore: u64 = (30u64 * 8)
.wrapping_mul(::core::mem::size_of::<usize>() as u64)
.wrapping_mul(::core::mem::size_of::<u64>() as u64)
.wrapping_add(100u64);
hasher.PrepareDistanceCache(dist_cache);
while position.wrapping_add(hasher.HashTypeLength()) < pos_end {
Expand Down

0 comments on commit df3236a

Please sign in to comment.