mirror of
https://github.com/facebook/zstd.git
synced 2025-11-25 23:43:06 +03:00
Merge pull request #984 from terrelln/dict-load
Load more dictionary positions into table if empty
This commit is contained in:
@@ -21,12 +21,23 @@ void ZSTD_fillDoubleHashTable(ZSTD_CCtx* cctx, const void* end, const U32 mls)
|
|||||||
const BYTE* const base = cctx->base;
|
const BYTE* const base = cctx->base;
|
||||||
const BYTE* ip = base + cctx->nextToUpdate;
|
const BYTE* ip = base + cctx->nextToUpdate;
|
||||||
const BYTE* const iend = ((const BYTE*)end) - HASH_READ_SIZE;
|
const BYTE* const iend = ((const BYTE*)end) - HASH_READ_SIZE;
|
||||||
const size_t fastHashFillStep = 3;
|
const U32 fastHashFillStep = 3;
|
||||||
|
|
||||||
while(ip <= iend) {
|
/* Always insert every fastHashFillStep position into the hash tables.
|
||||||
hashSmall[ZSTD_hashPtr(ip, hBitsS, mls)] = (U32)(ip - base);
|
* Insert the other positions into the large hash table if their entry
|
||||||
hashLarge[ZSTD_hashPtr(ip, hBitsL, 8)] = (U32)(ip - base);
|
* is empty.
|
||||||
ip += fastHashFillStep;
|
*/
|
||||||
|
for (; ip + fastHashFillStep - 1 <= iend; ip += fastHashFillStep) {
|
||||||
|
U32 const current = (U32)(ip - base);
|
||||||
|
U32 i;
|
||||||
|
for (i = 0; i < fastHashFillStep; ++i) {
|
||||||
|
size_t const smHash = ZSTD_hashPtr(ip + i, hBitsS, mls);
|
||||||
|
size_t const lgHash = ZSTD_hashPtr(ip + i, hBitsL, 8);
|
||||||
|
if (i == 0)
|
||||||
|
hashSmall[smHash] = current + i;
|
||||||
|
if (i == 0 || hashLarge[lgHash] == 0)
|
||||||
|
hashLarge[lgHash] = current + i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,19 @@ void ZSTD_fillHashTable (ZSTD_CCtx* zc, const void* end, const U32 mls)
|
|||||||
const BYTE* const base = zc->base;
|
const BYTE* const base = zc->base;
|
||||||
const BYTE* ip = base + zc->nextToUpdate;
|
const BYTE* ip = base + zc->nextToUpdate;
|
||||||
const BYTE* const iend = ((const BYTE*)end) - HASH_READ_SIZE;
|
const BYTE* const iend = ((const BYTE*)end) - HASH_READ_SIZE;
|
||||||
const size_t fastHashFillStep = 3;
|
const U32 fastHashFillStep = 3;
|
||||||
|
|
||||||
while(ip <= iend) {
|
/* Always insert every fastHashFillStep position into the hash table.
|
||||||
hashTable[ZSTD_hashPtr(ip, hBits, mls)] = (U32)(ip - base);
|
* Insert the other positions if their hash entry is empty.
|
||||||
ip += fastHashFillStep;
|
*/
|
||||||
|
for (; ip + fastHashFillStep - 1 <= iend; ip += fastHashFillStep) {
|
||||||
|
U32 const current = (U32)(ip - base);
|
||||||
|
U32 i;
|
||||||
|
for (i = 0; i < fastHashFillStep; ++i) {
|
||||||
|
size_t const hash = ZSTD_hashPtr(ip + i, hBits, mls);
|
||||||
|
if (i == 0 || hashTable[hash] == 0)
|
||||||
|
hashTable[hash] = current + i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user