mirror of https://git.tukaani.org/xz.git
liblzma: LZMA decoder: Optimize loop comparison.
But now it needs one more local variable.
This commit is contained in:
parent
88276f9f2c
commit
5e04706b91
|
@ -261,7 +261,7 @@ lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr,
|
|||
const size_t dict_start = dict.pos;
|
||||
|
||||
// Range decoder
|
||||
rc_to_local(coder->rc, *in_pos);
|
||||
rc_to_local(coder->rc, *in_pos, LZMA_IN_REQUIRED);
|
||||
|
||||
// State
|
||||
uint32_t state = coder->state;
|
||||
|
@ -340,8 +340,7 @@ lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr,
|
|||
|
||||
// If there is not enough room for another LZMA symbol
|
||||
// go to Resumable mode.
|
||||
if (unlikely(rc_in_end - rc_in_ptr < LZMA_IN_REQUIRED
|
||||
|| dict.pos == dict.limit))
|
||||
if (unlikely(!rc_is_fast_allowed() || dict.pos == dict.limit))
|
||||
goto slow;
|
||||
|
||||
// Decode the first bit from the next LZMA symbol.
|
||||
|
|
|
@ -61,13 +61,21 @@ rc_read_init(lzma_range_decoder *rc, const uint8_t *restrict in,
|
|||
/// Makes local copies of range decoder and *in_pos variables. Doing this
|
||||
/// improves speed significantly. The range decoder macros expect also
|
||||
/// variables 'in' and 'in_size' to be defined.
|
||||
#define rc_to_local(range_decoder, in_pos) \
|
||||
#define rc_to_local(range_decoder, in_pos, fast_mode_in_required) \
|
||||
lzma_range_decoder rc = range_decoder; \
|
||||
const uint8_t *rc_in_ptr = in + (in_pos); \
|
||||
const uint8_t *rc_in_end = in + in_size; \
|
||||
const uint8_t *rc_in_fast_end \
|
||||
= (rc_in_end - rc_in_ptr) <= (fast_mode_in_required) \
|
||||
? rc_in_ptr \
|
||||
: rc_in_end - (fast_mode_in_required); \
|
||||
uint32_t rc_bound
|
||||
|
||||
|
||||
/// Evaluates to true if there is enough input remaining to use fast mode.
|
||||
#define rc_is_fast_allowed() (rc_in_ptr < rc_in_fast_end)
|
||||
|
||||
|
||||
/// Stores the local copes back to the range decoder structure.
|
||||
#define rc_from_local(range_decoder, in_pos) \
|
||||
do { \
|
||||
|
|
Loading…
Reference in New Issue