Skip to content

Commit

Permalink
Simplify static_dict
Browse files Browse the repository at this point in the history
* Convert `IsMatch(dict, ...)` into a member method. The original `IsMatch` is marked as deprecated - and we probably can delete it, but it will require a major release due to being a breaking change. So for now, lets keep it, but remove it when releasing a new breaking version
* Same for `BrotliFindAllStaticDictionaryMatches`
* lots of internal simplifications - like using direct comparisons, using bools, etc
  • Loading branch information
nyurik committed May 12, 2024
1 parent dac157a commit 4901706
Show file tree
Hide file tree
Showing 2 changed files with 435 additions and 489 deletions.
8 changes: 3 additions & 5 deletions src/enc/backward_references/hq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ use crate::enc::constants::{kCopyExtra, kInsExtra};
use crate::enc::encode;
use crate::enc::literal_cost::BrotliEstimateBitCostsForLiterals;
use crate::enc::static_dict::{
BrotliDictionary, BrotliFindAllStaticDictionaryMatches, FindMatchLengthWithLimit,
BROTLI_UNALIGNED_LOAD32,
BrotliDictionary, FindMatchLengthWithLimit, BROTLI_UNALIGNED_LOAD32,
};
use crate::enc::util::{floatX, FastLog2, FastLog2f64};

Expand Down Expand Up @@ -382,13 +381,12 @@ where
{
let minlen = max(4, best_len.wrapping_add(1));
if dictionary.is_some()
&& BrotliFindAllStaticDictionaryMatches(
dictionary.unwrap(),
&& dictionary.unwrap().find_all_matches(
&data[cur_ix_masked..],
minlen,
max_length,
&mut dict_matches[..],
) != 0
)
{
assert!(params.use_dictionary);
let maxlen = min(37, max_length);
Expand Down
Loading

0 comments on commit 4901706

Please sign in to comment.