Skip to content

Commit d73d808

Browse files
committed
fn ZSTD_updateFseStateWithDInfo: refactor to be a method
1 parent 192dd3f commit d73d808

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

lib/decompress/zstd_decompress_block.rs

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,15 +1547,12 @@ unsafe fn ZSTD_execSequenceSplitLitBuffer(
15471547
Ok(sequenceLength)
15481548
}
15491549

1550-
#[inline(always)]
1551-
fn ZSTD_updateFseStateWithDInfo(
1552-
DStatePtr: &mut ZSTD_fseState,
1553-
bitD: &mut BIT_DStream_t,
1554-
nextState: u16,
1555-
nbBits: u32,
1556-
) {
1557-
let lowBits = bitD.read_bits(nbBits);
1558-
DStatePtr.state = usize::from(nextState) + lowBits;
1550+
impl ZSTD_fseState<'_> {
1551+
#[inline(always)]
1552+
fn update_with_d_info(&mut self, bitD: &mut BIT_DStream_t, nextState: u16, nbBits: u32) {
1553+
let lowBits = bitD.read_bits(nbBits);
1554+
self.state = usize::from(nextState) + lowBits;
1555+
}
15591556
}
15601557

15611558
/// We need to add at most `(ZSTD_WINDOWLOG_MAX_32 - 1)` bits to read the maximum
@@ -1694,27 +1691,18 @@ fn ZSTD_decodeSequence(
16941691

16951692
// Don't update FSE state for last Sequence.
16961693
if !is_last_sequence {
1697-
ZSTD_updateFseStateWithDInfo(
1698-
&mut seqState.stateLL,
1699-
&mut seqState.DStream,
1700-
llNext,
1701-
llnbBits,
1702-
);
1703-
ZSTD_updateFseStateWithDInfo(
1704-
&mut seqState.stateML,
1705-
&mut seqState.DStream,
1706-
mlNext,
1707-
mlnbBits,
1708-
);
1694+
seqState
1695+
.stateLL
1696+
.update_with_d_info(&mut seqState.DStream, llNext, llnbBits);
1697+
seqState
1698+
.stateML
1699+
.update_with_d_info(&mut seqState.DStream, mlNext, mlnbBits);
17091700
if MEM_32bits() {
17101701
seqState.DStream.reload();
17111702
}
1712-
ZSTD_updateFseStateWithDInfo(
1713-
&mut seqState.stateOffb,
1714-
&mut seqState.DStream,
1715-
ofNext,
1716-
ofnbBits,
1717-
);
1703+
seqState
1704+
.stateOffb
1705+
.update_with_d_info(&mut seqState.DStream, ofNext, ofnbBits);
17181706
seqState.DStream.reload();
17191707
}
17201708

0 commit comments

Comments
 (0)