summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2022-09-13 23:49:48 (GMT)
committerYann Collet <cyan@fb.com>2022-09-16 16:34:15 (GMT)
commit2620c0924bd69f7fc30cd76239d3808b3b5c5e6d (patch)
treeb00a48000769bd62a413b77d26429fadeecd2eed
parente84f375421c131a61d096cc5649b05119b87a7a1 (diff)
downloadlz4-2620c0924bd69f7fc30cd76239d3808b3b5c5e6d.zip
lz4-2620c0924bd69f7fc30cd76239d3808b3b5c5e6d.tar.gz
lz4-2620c0924bd69f7fc30cd76239d3808b3b5c5e6d.tar.bz2
remove another usage of base
within `LZ4_loadDict()` function : it's possible to only employ Indexes directly.
-rw-r--r--lib/lz4.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 3d5fba6..ee6d209 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1222,6 +1222,7 @@ _next_match:
if (dictDirective == usingDictCtx) {
if (matchIndex < startIndex) {
/* there was no match, try the dictionary */
+ assert(tableType == byU32);
matchIndex = LZ4_getIndexOnHash(h, dictCtx->hashTable, byU32);
match = dictBase + matchIndex;
lowLimit = dictionary; /* required for match length counter */
@@ -1542,7 +1543,7 @@ int LZ4_loadDict (LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize)
const tableType_t tableType = byU32;
const BYTE* p = (const BYTE*)dictionary;
const BYTE* const dictEnd = p + dictSize;
- const BYTE* base;
+ U32 idx32;
DEBUGLOG(4, "LZ4_loadDict (%i bytes from %p into %p)", dictSize, dictionary, LZ4_dict);
@@ -1565,14 +1566,15 @@ int LZ4_loadDict (LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize)
}
if ((dictEnd - p) > 64 KB) p = dictEnd - 64 KB;
- base = dictEnd - dict->currentOffset;
dict->dictionary = p;
dict->dictSize = (U32)(dictEnd - p);
dict->tableType = (U32)tableType;
+ idx32 = dict->currentOffset - dict->dictSize;
while (p <= dictEnd-HASH_UNIT) {
- LZ4_putPosition(p, dict->hashTable, tableType, base);
- p+=3;
+ U32 const h = LZ4_hashPosition(p, tableType);
+ LZ4_putIndexOnHash(idx32, h, dict->hashTable, tableType);
+ p+=3; idx32+=3;
}
return (int)dict->dictSize;