mirror of
https://git.tukaani.org/xz.git
synced 2025-04-10 01:31:13 +00:00
liblzma: Define LZ_DICT_INIT_POS for initial dictionary position
It's more readable.
This commit is contained in:
parent
8e7cd0091e
commit
e82ee090c5
@ -53,9 +53,9 @@ typedef struct {
|
|||||||
static void
|
static void
|
||||||
lz_decoder_reset(lzma_coder *coder)
|
lz_decoder_reset(lzma_coder *coder)
|
||||||
{
|
{
|
||||||
coder->dict.pos = 2 * LZ_DICT_REPEAT_MAX;
|
coder->dict.pos = LZ_DICT_INIT_POS;
|
||||||
coder->dict.full = 0;
|
coder->dict.full = 0;
|
||||||
coder->dict.buf[2 * LZ_DICT_REPEAT_MAX - 1] = '\0';
|
coder->dict.buf[LZ_DICT_INIT_POS - 1] = '\0';
|
||||||
coder->dict.has_wrapped = false;
|
coder->dict.has_wrapped = false;
|
||||||
coder->dict.need_reset = false;
|
coder->dict.need_reset = false;
|
||||||
return;
|
return;
|
||||||
|
@ -35,6 +35,9 @@
|
|||||||
/// LZMA's longest match length is 273 so pick a multiple of 16 above that.
|
/// LZMA's longest match length is 273 so pick a multiple of 16 above that.
|
||||||
#define LZ_DICT_REPEAT_MAX 288
|
#define LZ_DICT_REPEAT_MAX 288
|
||||||
|
|
||||||
|
/// Initial position in lzma_dict.buf when the dictionary is empty.
|
||||||
|
#define LZ_DICT_INIT_POS (2 * LZ_DICT_REPEAT_MAX)
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/// Pointer to the dictionary buffer.
|
/// Pointer to the dictionary buffer.
|
||||||
@ -185,7 +188,7 @@ dict_repeat(lzma_dict *dict, uint32_t distance, uint32_t *len)
|
|||||||
|
|
||||||
// Update how full the dictionary is.
|
// Update how full the dictionary is.
|
||||||
if (!dict->has_wrapped)
|
if (!dict->has_wrapped)
|
||||||
dict->full = dict->pos - 2 * LZ_DICT_REPEAT_MAX;
|
dict->full = dict->pos - LZ_DICT_INIT_POS;
|
||||||
|
|
||||||
return *len != 0;
|
return *len != 0;
|
||||||
}
|
}
|
||||||
@ -197,7 +200,7 @@ dict_put(lzma_dict *dict, uint8_t byte)
|
|||||||
dict->buf[dict->pos++] = byte;
|
dict->buf[dict->pos++] = byte;
|
||||||
|
|
||||||
if (!dict->has_wrapped)
|
if (!dict->has_wrapped)
|
||||||
dict->full = dict->pos - 2 * LZ_DICT_REPEAT_MAX;
|
dict->full = dict->pos - LZ_DICT_INIT_POS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -234,7 +237,7 @@ dict_write(lzma_dict *restrict dict, const uint8_t *restrict in,
|
|||||||
dict->buf, &dict->pos, dict->limit);
|
dict->buf, &dict->pos, dict->limit);
|
||||||
|
|
||||||
if (!dict->has_wrapped)
|
if (!dict->has_wrapped)
|
||||||
dict->full = dict->pos - 2 * LZ_DICT_REPEAT_MAX;
|
dict->full = dict->pos - LZ_DICT_INIT_POS;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user