diff options
author | Yann Collet <cyan@fb.com> | 2022-09-13 23:49:48 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2022-09-16 16:34:15 (GMT) |
commit | 2620c0924bd69f7fc30cd76239d3808b3b5c5e6d (patch) | |
tree | b00a48000769bd62a413b77d26429fadeecd2eed /lib/lz4.c | |
parent | e84f375421c131a61d096cc5649b05119b87a7a1 (diff) | |
download | lz4-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.
Diffstat (limited to 'lib/lz4.c')
-rw-r--r-- | lib/lz4.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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; |