diff options
author | Yann Collet <cyan@fb.com> | 2018-04-17 19:07:22 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2018-04-17 19:07:22 (GMT) |
commit | ce78d10c1f8afd13fbea0071c70d48c8744e43d2 (patch) | |
tree | 8cf021489500169214fef732392d98aa8f2d41d6 /lib | |
parent | da3b5ba6f0014564b7312511e441067ba9429733 (diff) | |
parent | a35aba6d747854f8b0d7137c7d3dbc67f6a9fb33 (diff) | |
download | lz4-ce78d10c1f8afd13fbea0071c70d48c8744e43d2.zip lz4-ce78d10c1f8afd13fbea0071c70d48c8744e43d2.tar.gz lz4-ce78d10c1f8afd13fbea0071c70d48c8744e43d2.tar.bz2 |
Merge branch 'dev' into lowAddr
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lz4.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -1294,11 +1294,18 @@ int LZ4_loadDict (LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize) LZ4_prepareTable(dict, 0, tableType); + /* We always increment the offset by 64 KB, since, if the dict is longer, + * we truncate it to the last 64k, and if it's shorter, we still want to + * advance by a whole window length so we can provide the guarantee that + * there are only valid offsets in the window, which allows an optimization + * in LZ4_compress_fast_continue() where it uses noDictIssue even when the + * dictionary isn't a full 64k. */ + if ((dictEnd - p) > 64 KB) p = dictEnd - 64 KB; - base = p - dict->currentOffset; + base = dictEnd - 64 KB - dict->currentOffset; dict->dictionary = p; dict->dictSize = (U32)(dictEnd - p); - dict->currentOffset += dict->dictSize; + dict->currentOffset += 64 KB; dict->tableType = tableType; if (dictSize < (int)HASH_UNIT) { |