Merge pull request #1681 from facebook/level3

updated double_fast complementary insertion
This commit is contained in:
Yann Collet 2019-07-12 16:16:06 -07:00 committed by GitHub
commit 8fb08b68cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 12 deletions

2
.gitignore vendored
View File

@ -14,7 +14,7 @@
*.dylib *.dylib
# Executables # Executables
zstd. /zstd
zstdmt zstdmt
*.exe *.exe
*.out *.out

View File

@ -254,11 +254,14 @@ _match_stored:
anchor = ip; anchor = ip;
if (ip <= ilimit) { if (ip <= ilimit) {
/* Fill Table */ /* Complementary insertion */
hashLong[ZSTD_hashPtr(base+current+2, hBitsL, 8)] = /* done after iLimit test, as candidates could be > iend-8 */
hashSmall[ZSTD_hashPtr(base+current+2, hBitsS, mls)] = current+2; /* here because current+2 could be > iend-8 */ { U32 const indexToInsert = current+2;
hashLong[ZSTD_hashPtr(ip-2, hBitsL, 8)] = hashLong[ZSTD_hashPtr(base+indexToInsert, hBitsL, 8)] = indexToInsert;
hashSmall[ZSTD_hashPtr(ip-2, hBitsS, mls)] = (U32)(ip-2-base); hashLong[ZSTD_hashPtr(ip-2, hBitsL, 8)] = (U32)(ip-2-base);
hashSmall[ZSTD_hashPtr(base+indexToInsert, hBitsS, mls)] = indexToInsert;
hashSmall[ZSTD_hashPtr(ip-1, hBitsS, mls)] = (U32)(ip-1-base);
}
/* check immediate repcode */ /* check immediate repcode */
if (dictMode == ZSTD_dictMatchState) { if (dictMode == ZSTD_dictMatchState) {
@ -452,16 +455,20 @@ static size_t ZSTD_compressBlock_doubleFast_extDict_generic(
continue; continue;
} } } }
/* found a match : store it */ /* move to next sequence start */
ip += mLength; ip += mLength;
anchor = ip; anchor = ip;
if (ip <= ilimit) { if (ip <= ilimit) {
/* Fill Table */ /* Complementary insertion */
hashSmall[ZSTD_hashPtr(base+current+2, hBitsS, mls)] = current+2; /* done after iLimit test, as candidates could be > iend-8 */
hashLong[ZSTD_hashPtr(base+current+2, hBitsL, 8)] = current+2; { U32 const indexToInsert = current+2;
hashSmall[ZSTD_hashPtr(ip-2, hBitsS, mls)] = (U32)(ip-2-base); hashLong[ZSTD_hashPtr(base+indexToInsert, hBitsL, 8)] = indexToInsert;
hashLong[ZSTD_hashPtr(ip-2, hBitsL, 8)] = (U32)(ip-2-base); hashLong[ZSTD_hashPtr(ip-2, hBitsL, 8)] = (U32)(ip-2-base);
hashSmall[ZSTD_hashPtr(base+indexToInsert, hBitsS, mls)] = indexToInsert;
hashSmall[ZSTD_hashPtr(ip-1, hBitsS, mls)] = (U32)(ip-1-base);
}
/* check immediate repcode */ /* check immediate repcode */
while (ip <= ilimit) { while (ip <= ilimit) {
U32 const current2 = (U32)(ip-base); U32 const current2 = (U32)(ip-base);