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 21, 2024
1 parent 8606c1f commit 47150ad
Showing 1 changed file with 10 additions and 10 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 @@ -211,7 +211,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 @@ -435,7 +435,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 @@ -466,8 +466,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 @@ -500,8 +500,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 @@ -519,8 +519,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 @@ -548,8 +548,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

0 comments on commit 47150ad

Please sign in to comment.