Skip to content

Commit

Permalink
improve initing the decoder from a dict
Browse files Browse the repository at this point in the history
  • Loading branch information
KillingSpark committed Mar 30, 2023
1 parent 0b9331d commit f3f09c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/decoding/scratch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ impl DecoderScratch {
self.huf.table.reset();
}

pub fn use_dict(&mut self, dict: &Dictionary) {
pub fn init_from_dict(&mut self, dict: &Dictionary) {
self.fse.reinit_from(&dict.fse);
self.huf.table.reinit_from(&dict.huf.table);
self.offset_hist = dict.offset_hist;
self.buffer.dict_content = dict.dict_content.clone();
self.buffer.dict_content.clear();
self.buffer.dict_content.extend_from_slice(&dict.dict_content);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/frame_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl FrameDecoder {
}
None => {
let dict = self.dicts.get(&id).ok_or(err::DictNotProvided)?;
state.decoder_scratch.use_dict(dict);
state.decoder_scratch.init_from_dict(dict);
state.using_dict = Some(id);
}
}
Expand Down Expand Up @@ -455,7 +455,7 @@ impl FrameDecoder {
}
None => {
let dict = self.dicts.get(&id).ok_or(err::DictNotProvided)?;
state.decoder_scratch.use_dict(dict);
state.decoder_scratch.init_from_dict(dict);
state.using_dict = Some(id);
}
}
Expand Down

0 comments on commit f3f09c7

Please sign in to comment.