Skip to content

Commit

Permalink
Convert to bool BasicHashComputer::use_dictionary and proper case
Browse files Browse the repository at this point in the history
Since this is a breaking change, refactoring the naming as well (perhaps should rename other trait methods for consistency?)
  • Loading branch information
nyurik committed May 27, 2024
1 parent 85196be commit 072cca6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 10 additions & 10 deletions src/enc/backward_references/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub fn StoreLookaheadThenStore<T: AnyHasher>(hasher: &mut T, size: usize, dict:
pub trait BasicHashComputer {
fn HashBytes(&self, data: &[u8]) -> u32;
fn BUCKET_BITS(&self) -> i32;
fn USE_DICTIONARY(&self) -> i32;
fn use_dictionary(&self) -> bool;
fn BUCKET_SWEEP(&self) -> i32;
}
pub struct BasicHasher<Buckets: SliceWrapperMut<u32> + SliceWrapper<u32> + BasicHashComputer> {
Expand Down Expand Up @@ -431,7 +431,7 @@ impl<T: SliceWrapperMut<u32> + SliceWrapper<u32> + BasicHashComputer> AnyHasher
}
}
}
if dictionary.is_some() && self.buckets_.USE_DICTIONARY() != 0 && !is_match_found {
if dictionary.is_some() && self.buckets_.use_dictionary() && !is_match_found {
is_match_found = SearchInStaticDictionary(
dictionary.unwrap(),
dictionary_hash,
Expand Down Expand Up @@ -462,8 +462,8 @@ impl<AllocU32: alloc::Allocator<u32>> BasicHashComputer for H2Sub<AllocU32> {
fn BUCKET_SWEEP(&self) -> i32 {
1
}
fn USE_DICTIONARY(&self) -> i32 {
1
fn use_dictionary(&self) -> bool {
true
}
}
impl<AllocU32: alloc::Allocator<u32>> SliceWrapperMut<u32> for H2Sub<AllocU32> {
Expand Down Expand Up @@ -496,8 +496,8 @@ impl<AllocU32: alloc::Allocator<u32>> BasicHashComputer for H3Sub<AllocU32> {
fn BUCKET_SWEEP(&self) -> i32 {
2
}
fn USE_DICTIONARY(&self) -> i32 {
0
fn use_dictionary(&self) -> bool {
false
}
fn HashBytes(&self, data: &[u8]) -> u32 {
let h: u64 =
Expand All @@ -515,8 +515,8 @@ impl<AllocU32: alloc::Allocator<u32>> BasicHashComputer for H4Sub<AllocU32> {
fn BUCKET_SWEEP(&self) -> i32 {
4
}
fn USE_DICTIONARY(&self) -> i32 {
1
fn use_dictionary(&self) -> bool {
true
}
fn HashBytes(&self, data: &[u8]) -> u32 {
let h: u64 =
Expand Down Expand Up @@ -544,8 +544,8 @@ impl<AllocU32: alloc::Allocator<u32>> BasicHashComputer for H54Sub<AllocU32> {
fn BUCKET_SWEEP(&self) -> i32 {
4
}
fn USE_DICTIONARY(&self) -> i32 {
0
fn use_dictionary(&self) -> bool {
false
}
fn HashBytes(&self, data: &[u8]) -> u32 {
let h: u64 =
Expand Down
2 changes: 0 additions & 2 deletions src/enc/bit_cost.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use alloc::SliceWrapperMut;

use core::cmp::{max, min};

use super::super::alloc::SliceWrapper;
Expand All @@ -8,7 +7,6 @@ use super::util::{FastLog2, FastLog2u16};
use super::vectorization::Mem256i;
use crate::enc::floatX;


const BROTLI_REPEAT_ZERO_CODE_LENGTH: usize = 17;
const BROTLI_CODE_LENGTH_CODES: usize = BROTLI_REPEAT_ZERO_CODE_LENGTH + 1;

Expand Down

0 comments on commit 072cca6

Please sign in to comment.