zstd-ruby 1.5.2.2 → 1.5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +15 -3
- data/ext/zstdruby/common.h +7 -0
- data/ext/zstdruby/libzstd/common/bits.h +175 -0
- data/ext/zstdruby/libzstd/common/bitstream.h +18 -59
- data/ext/zstdruby/libzstd/common/compiler.h +22 -3
- data/ext/zstdruby/libzstd/common/cpu.h +1 -1
- data/ext/zstdruby/libzstd/common/debug.c +1 -1
- data/ext/zstdruby/libzstd/common/debug.h +1 -1
- data/ext/zstdruby/libzstd/common/entropy_common.c +12 -40
- data/ext/zstdruby/libzstd/common/error_private.c +9 -2
- data/ext/zstdruby/libzstd/common/error_private.h +1 -1
- data/ext/zstdruby/libzstd/common/fse.h +5 -83
- data/ext/zstdruby/libzstd/common/fse_decompress.c +7 -99
- data/ext/zstdruby/libzstd/common/huf.h +65 -156
- data/ext/zstdruby/libzstd/common/mem.h +39 -46
- data/ext/zstdruby/libzstd/common/pool.c +26 -10
- data/ext/zstdruby/libzstd/common/pool.h +7 -1
- data/ext/zstdruby/libzstd/common/portability_macros.h +22 -3
- data/ext/zstdruby/libzstd/common/threading.c +68 -14
- data/ext/zstdruby/libzstd/common/threading.h +5 -10
- data/ext/zstdruby/libzstd/common/xxhash.c +2 -2
- data/ext/zstdruby/libzstd/common/xxhash.h +8 -8
- data/ext/zstdruby/libzstd/common/zstd_common.c +1 -1
- data/ext/zstdruby/libzstd/common/zstd_deps.h +1 -1
- data/ext/zstdruby/libzstd/common/zstd_internal.h +17 -113
- data/ext/zstdruby/libzstd/common/zstd_trace.h +3 -3
- data/ext/zstdruby/libzstd/compress/clevels.h +1 -1
- data/ext/zstdruby/libzstd/compress/fse_compress.c +7 -124
- data/ext/zstdruby/libzstd/compress/hist.c +1 -1
- data/ext/zstdruby/libzstd/compress/hist.h +1 -1
- data/ext/zstdruby/libzstd/compress/huf_compress.c +234 -169
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +1055 -455
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +165 -145
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +115 -39
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +16 -8
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +3 -3
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +25 -21
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +5 -3
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +95 -33
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +3 -2
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +433 -148
- data/ext/zstdruby/libzstd/compress/zstd_fast.h +3 -2
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +306 -283
- data/ext/zstdruby/libzstd/compress/zstd_lazy.h +4 -2
- data/ext/zstdruby/libzstd/compress/zstd_ldm.c +5 -5
- data/ext/zstdruby/libzstd/compress/zstd_ldm.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +104 -80
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +12 -5
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +1 -1
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +434 -441
- data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +30 -39
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +3 -4
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +1 -1
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +164 -42
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +186 -65
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +1 -1
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +4 -2
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +19 -15
- data/ext/zstdruby/libzstd/dictBuilder/cover.h +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +2 -2
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +9 -87
- data/ext/zstdruby/libzstd/zdict.h +53 -31
- data/ext/zstdruby/libzstd/zstd.h +489 -90
- data/ext/zstdruby/libzstd/zstd_errors.h +27 -8
- data/ext/zstdruby/main.c +4 -0
- data/ext/zstdruby/streaming_compress.c +1 -7
- data/ext/zstdruby/zstdruby.c +110 -26
- data/lib/zstd-ruby/version.rb +1 -1
- data/lib/zstd-ruby.rb +0 -1
- metadata +7 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under both the BSD-style license (found in the
|
|
@@ -11,8 +11,43 @@
|
|
|
11
11
|
#include "zstd_compress_internal.h"
|
|
12
12
|
#include "zstd_double_fast.h"
|
|
13
13
|
|
|
14
|
+
static void ZSTD_fillDoubleHashTableForCDict(ZSTD_matchState_t* ms,
|
|
15
|
+
void const* end, ZSTD_dictTableLoadMethod_e dtlm)
|
|
16
|
+
{
|
|
17
|
+
const ZSTD_compressionParameters* const cParams = &ms->cParams;
|
|
18
|
+
U32* const hashLarge = ms->hashTable;
|
|
19
|
+
U32 const hBitsL = cParams->hashLog + ZSTD_SHORT_CACHE_TAG_BITS;
|
|
20
|
+
U32 const mls = cParams->minMatch;
|
|
21
|
+
U32* const hashSmall = ms->chainTable;
|
|
22
|
+
U32 const hBitsS = cParams->chainLog + ZSTD_SHORT_CACHE_TAG_BITS;
|
|
23
|
+
const BYTE* const base = ms->window.base;
|
|
24
|
+
const BYTE* ip = base + ms->nextToUpdate;
|
|
25
|
+
const BYTE* const iend = ((const BYTE*)end) - HASH_READ_SIZE;
|
|
26
|
+
const U32 fastHashFillStep = 3;
|
|
14
27
|
|
|
15
|
-
|
|
28
|
+
/* Always insert every fastHashFillStep position into the hash tables.
|
|
29
|
+
* Insert the other positions into the large hash table if their entry
|
|
30
|
+
* is empty.
|
|
31
|
+
*/
|
|
32
|
+
for (; ip + fastHashFillStep - 1 <= iend; ip += fastHashFillStep) {
|
|
33
|
+
U32 const curr = (U32)(ip - base);
|
|
34
|
+
U32 i;
|
|
35
|
+
for (i = 0; i < fastHashFillStep; ++i) {
|
|
36
|
+
size_t const smHashAndTag = ZSTD_hashPtr(ip + i, hBitsS, mls);
|
|
37
|
+
size_t const lgHashAndTag = ZSTD_hashPtr(ip + i, hBitsL, 8);
|
|
38
|
+
if (i == 0) {
|
|
39
|
+
ZSTD_writeTaggedIndex(hashSmall, smHashAndTag, curr + i);
|
|
40
|
+
}
|
|
41
|
+
if (i == 0 || hashLarge[lgHashAndTag >> ZSTD_SHORT_CACHE_TAG_BITS] == 0) {
|
|
42
|
+
ZSTD_writeTaggedIndex(hashLarge, lgHashAndTag, curr + i);
|
|
43
|
+
}
|
|
44
|
+
/* Only load extra positions for ZSTD_dtlm_full */
|
|
45
|
+
if (dtlm == ZSTD_dtlm_fast)
|
|
46
|
+
break;
|
|
47
|
+
} }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static void ZSTD_fillDoubleHashTableForCCtx(ZSTD_matchState_t* ms,
|
|
16
51
|
void const* end, ZSTD_dictTableLoadMethod_e dtlm)
|
|
17
52
|
{
|
|
18
53
|
const ZSTD_compressionParameters* const cParams = &ms->cParams;
|
|
@@ -43,7 +78,19 @@ void ZSTD_fillDoubleHashTable(ZSTD_matchState_t* ms,
|
|
|
43
78
|
/* Only load extra positions for ZSTD_dtlm_full */
|
|
44
79
|
if (dtlm == ZSTD_dtlm_fast)
|
|
45
80
|
break;
|
|
46
|
-
|
|
81
|
+
} }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
void ZSTD_fillDoubleHashTable(ZSTD_matchState_t* ms,
|
|
85
|
+
const void* const end,
|
|
86
|
+
ZSTD_dictTableLoadMethod_e dtlm,
|
|
87
|
+
ZSTD_tableFillPurpose_e tfp)
|
|
88
|
+
{
|
|
89
|
+
if (tfp == ZSTD_tfp_forCDict) {
|
|
90
|
+
ZSTD_fillDoubleHashTableForCDict(ms, end, dtlm);
|
|
91
|
+
} else {
|
|
92
|
+
ZSTD_fillDoubleHashTableForCCtx(ms, end, dtlm);
|
|
93
|
+
}
|
|
47
94
|
}
|
|
48
95
|
|
|
49
96
|
|
|
@@ -67,7 +114,7 @@ size_t ZSTD_compressBlock_doubleFast_noDict_generic(
|
|
|
67
114
|
const BYTE* const iend = istart + srcSize;
|
|
68
115
|
const BYTE* const ilimit = iend - HASH_READ_SIZE;
|
|
69
116
|
U32 offset_1=rep[0], offset_2=rep[1];
|
|
70
|
-
U32
|
|
117
|
+
U32 offsetSaved1 = 0, offsetSaved2 = 0;
|
|
71
118
|
|
|
72
119
|
size_t mLength;
|
|
73
120
|
U32 offset;
|
|
@@ -100,8 +147,8 @@ size_t ZSTD_compressBlock_doubleFast_noDict_generic(
|
|
|
100
147
|
U32 const current = (U32)(ip - base);
|
|
101
148
|
U32 const windowLow = ZSTD_getLowestPrefixIndex(ms, current, cParams->windowLog);
|
|
102
149
|
U32 const maxRep = current - windowLow;
|
|
103
|
-
if (offset_2 > maxRep)
|
|
104
|
-
if (offset_1 > maxRep)
|
|
150
|
+
if (offset_2 > maxRep) offsetSaved2 = offset_2, offset_2 = 0;
|
|
151
|
+
if (offset_1 > maxRep) offsetSaved1 = offset_1, offset_1 = 0;
|
|
105
152
|
}
|
|
106
153
|
|
|
107
154
|
/* Outer Loop: one iteration per match found and stored */
|
|
@@ -131,7 +178,7 @@ size_t ZSTD_compressBlock_doubleFast_noDict_generic(
|
|
|
131
178
|
if ((offset_1 > 0) & (MEM_read32(ip+1-offset_1) == MEM_read32(ip+1))) {
|
|
132
179
|
mLength = ZSTD_count(ip+1+4, ip+1+4-offset_1, iend) + 4;
|
|
133
180
|
ip++;
|
|
134
|
-
ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend,
|
|
181
|
+
ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend, REPCODE1_TO_OFFBASE, mLength);
|
|
135
182
|
goto _match_stored;
|
|
136
183
|
}
|
|
137
184
|
|
|
@@ -175,9 +222,13 @@ size_t ZSTD_compressBlock_doubleFast_noDict_generic(
|
|
|
175
222
|
} while (ip1 <= ilimit);
|
|
176
223
|
|
|
177
224
|
_cleanup:
|
|
225
|
+
/* If offset_1 started invalid (offsetSaved1 != 0) and became valid (offset_1 != 0),
|
|
226
|
+
* rotate saved offsets. See comment in ZSTD_compressBlock_fast_noDict for more context. */
|
|
227
|
+
offsetSaved2 = ((offsetSaved1 != 0) && (offset_1 != 0)) ? offsetSaved1 : offsetSaved2;
|
|
228
|
+
|
|
178
229
|
/* save reps for next block */
|
|
179
|
-
rep[0] = offset_1 ? offset_1 :
|
|
180
|
-
rep[1] = offset_2 ? offset_2 :
|
|
230
|
+
rep[0] = offset_1 ? offset_1 : offsetSaved1;
|
|
231
|
+
rep[1] = offset_2 ? offset_2 : offsetSaved2;
|
|
181
232
|
|
|
182
233
|
/* Return the last literals size */
|
|
183
234
|
return (size_t)(iend - anchor);
|
|
@@ -217,7 +268,7 @@ _match_found: /* requires ip, offset, mLength */
|
|
|
217
268
|
hashLong[hl1] = (U32)(ip1 - base);
|
|
218
269
|
}
|
|
219
270
|
|
|
220
|
-
ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend,
|
|
271
|
+
ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend, OFFSET_TO_OFFBASE(offset), mLength);
|
|
221
272
|
|
|
222
273
|
_match_stored:
|
|
223
274
|
/* match found */
|
|
@@ -243,7 +294,7 @@ _match_stored:
|
|
|
243
294
|
U32 const tmpOff = offset_2; offset_2 = offset_1; offset_1 = tmpOff; /* swap offset_2 <=> offset_1 */
|
|
244
295
|
hashSmall[ZSTD_hashPtr(ip, hBitsS, mls)] = (U32)(ip-base);
|
|
245
296
|
hashLong[ZSTD_hashPtr(ip, hBitsL, 8)] = (U32)(ip-base);
|
|
246
|
-
ZSTD_storeSeq(seqStore, 0, anchor, iend,
|
|
297
|
+
ZSTD_storeSeq(seqStore, 0, anchor, iend, REPCODE1_TO_OFFBASE, rLength);
|
|
247
298
|
ip += rLength;
|
|
248
299
|
anchor = ip;
|
|
249
300
|
continue; /* faster when present ... (?) */
|
|
@@ -275,7 +326,6 @@ size_t ZSTD_compressBlock_doubleFast_dictMatchState_generic(
|
|
|
275
326
|
const BYTE* const iend = istart + srcSize;
|
|
276
327
|
const BYTE* const ilimit = iend - HASH_READ_SIZE;
|
|
277
328
|
U32 offset_1=rep[0], offset_2=rep[1];
|
|
278
|
-
U32 offsetSaved = 0;
|
|
279
329
|
|
|
280
330
|
const ZSTD_matchState_t* const dms = ms->dictMatchState;
|
|
281
331
|
const ZSTD_compressionParameters* const dictCParams = &dms->cParams;
|
|
@@ -286,8 +336,8 @@ size_t ZSTD_compressBlock_doubleFast_dictMatchState_generic(
|
|
|
286
336
|
const BYTE* const dictStart = dictBase + dictStartIndex;
|
|
287
337
|
const BYTE* const dictEnd = dms->window.nextSrc;
|
|
288
338
|
const U32 dictIndexDelta = prefixLowestIndex - (U32)(dictEnd - dictBase);
|
|
289
|
-
const U32 dictHBitsL = dictCParams->hashLog;
|
|
290
|
-
const U32 dictHBitsS = dictCParams->chainLog;
|
|
339
|
+
const U32 dictHBitsL = dictCParams->hashLog + ZSTD_SHORT_CACHE_TAG_BITS;
|
|
340
|
+
const U32 dictHBitsS = dictCParams->chainLog + ZSTD_SHORT_CACHE_TAG_BITS;
|
|
291
341
|
const U32 dictAndPrefixLength = (U32)((ip - prefixLowest) + (dictEnd - dictStart));
|
|
292
342
|
|
|
293
343
|
DEBUGLOG(5, "ZSTD_compressBlock_doubleFast_dictMatchState_generic");
|
|
@@ -295,6 +345,13 @@ size_t ZSTD_compressBlock_doubleFast_dictMatchState_generic(
|
|
|
295
345
|
/* if a dictionary is attached, it must be within window range */
|
|
296
346
|
assert(ms->window.dictLimit + (1U << cParams->windowLog) >= endIndex);
|
|
297
347
|
|
|
348
|
+
if (ms->prefetchCDictTables) {
|
|
349
|
+
size_t const hashTableBytes = (((size_t)1) << dictCParams->hashLog) * sizeof(U32);
|
|
350
|
+
size_t const chainTableBytes = (((size_t)1) << dictCParams->chainLog) * sizeof(U32);
|
|
351
|
+
PREFETCH_AREA(dictHashLong, hashTableBytes)
|
|
352
|
+
PREFETCH_AREA(dictHashSmall, chainTableBytes)
|
|
353
|
+
}
|
|
354
|
+
|
|
298
355
|
/* init */
|
|
299
356
|
ip += (dictAndPrefixLength == 0);
|
|
300
357
|
|
|
@@ -309,8 +366,12 @@ size_t ZSTD_compressBlock_doubleFast_dictMatchState_generic(
|
|
|
309
366
|
U32 offset;
|
|
310
367
|
size_t const h2 = ZSTD_hashPtr(ip, hBitsL, 8);
|
|
311
368
|
size_t const h = ZSTD_hashPtr(ip, hBitsS, mls);
|
|
312
|
-
size_t const
|
|
313
|
-
size_t const
|
|
369
|
+
size_t const dictHashAndTagL = ZSTD_hashPtr(ip, dictHBitsL, 8);
|
|
370
|
+
size_t const dictHashAndTagS = ZSTD_hashPtr(ip, dictHBitsS, mls);
|
|
371
|
+
U32 const dictMatchIndexAndTagL = dictHashLong[dictHashAndTagL >> ZSTD_SHORT_CACHE_TAG_BITS];
|
|
372
|
+
U32 const dictMatchIndexAndTagS = dictHashSmall[dictHashAndTagS >> ZSTD_SHORT_CACHE_TAG_BITS];
|
|
373
|
+
int const dictTagsMatchL = ZSTD_comparePackedTags(dictMatchIndexAndTagL, dictHashAndTagL);
|
|
374
|
+
int const dictTagsMatchS = ZSTD_comparePackedTags(dictMatchIndexAndTagS, dictHashAndTagS);
|
|
314
375
|
U32 const curr = (U32)(ip-base);
|
|
315
376
|
U32 const matchIndexL = hashLong[h2];
|
|
316
377
|
U32 matchIndexS = hashSmall[h];
|
|
@@ -328,7 +389,7 @@ size_t ZSTD_compressBlock_doubleFast_dictMatchState_generic(
|
|
|
328
389
|
const BYTE* repMatchEnd = repIndex < prefixLowestIndex ? dictEnd : iend;
|
|
329
390
|
mLength = ZSTD_count_2segments(ip+1+4, repMatch+4, iend, repMatchEnd, prefixLowest) + 4;
|
|
330
391
|
ip++;
|
|
331
|
-
ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend,
|
|
392
|
+
ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend, REPCODE1_TO_OFFBASE, mLength);
|
|
332
393
|
goto _match_stored;
|
|
333
394
|
}
|
|
334
395
|
|
|
@@ -340,9 +401,9 @@ size_t ZSTD_compressBlock_doubleFast_dictMatchState_generic(
|
|
|
340
401
|
while (((ip>anchor) & (matchLong>prefixLowest)) && (ip[-1] == matchLong[-1])) { ip--; matchLong--; mLength++; } /* catch up */
|
|
341
402
|
goto _match_found;
|
|
342
403
|
}
|
|
343
|
-
} else {
|
|
404
|
+
} else if (dictTagsMatchL) {
|
|
344
405
|
/* check dictMatchState long match */
|
|
345
|
-
U32 const dictMatchIndexL =
|
|
406
|
+
U32 const dictMatchIndexL = dictMatchIndexAndTagL >> ZSTD_SHORT_CACHE_TAG_BITS;
|
|
346
407
|
const BYTE* dictMatchL = dictBase + dictMatchIndexL;
|
|
347
408
|
assert(dictMatchL < dictEnd);
|
|
348
409
|
|
|
@@ -358,9 +419,9 @@ size_t ZSTD_compressBlock_doubleFast_dictMatchState_generic(
|
|
|
358
419
|
if (MEM_read32(match) == MEM_read32(ip)) {
|
|
359
420
|
goto _search_next_long;
|
|
360
421
|
}
|
|
361
|
-
} else {
|
|
422
|
+
} else if (dictTagsMatchS) {
|
|
362
423
|
/* check dictMatchState short match */
|
|
363
|
-
U32 const dictMatchIndexS =
|
|
424
|
+
U32 const dictMatchIndexS = dictMatchIndexAndTagS >> ZSTD_SHORT_CACHE_TAG_BITS;
|
|
364
425
|
match = dictBase + dictMatchIndexS;
|
|
365
426
|
matchIndexS = dictMatchIndexS + dictIndexDelta;
|
|
366
427
|
|
|
@@ -375,10 +436,11 @@ size_t ZSTD_compressBlock_doubleFast_dictMatchState_generic(
|
|
|
375
436
|
continue;
|
|
376
437
|
|
|
377
438
|
_search_next_long:
|
|
378
|
-
|
|
379
439
|
{ size_t const hl3 = ZSTD_hashPtr(ip+1, hBitsL, 8);
|
|
380
|
-
size_t const
|
|
440
|
+
size_t const dictHashAndTagL3 = ZSTD_hashPtr(ip+1, dictHBitsL, 8);
|
|
381
441
|
U32 const matchIndexL3 = hashLong[hl3];
|
|
442
|
+
U32 const dictMatchIndexAndTagL3 = dictHashLong[dictHashAndTagL3 >> ZSTD_SHORT_CACHE_TAG_BITS];
|
|
443
|
+
int const dictTagsMatchL3 = ZSTD_comparePackedTags(dictMatchIndexAndTagL3, dictHashAndTagL3);
|
|
382
444
|
const BYTE* matchL3 = base + matchIndexL3;
|
|
383
445
|
hashLong[hl3] = curr + 1;
|
|
384
446
|
|
|
@@ -391,9 +453,9 @@ _search_next_long:
|
|
|
391
453
|
while (((ip>anchor) & (matchL3>prefixLowest)) && (ip[-1] == matchL3[-1])) { ip--; matchL3--; mLength++; } /* catch up */
|
|
392
454
|
goto _match_found;
|
|
393
455
|
}
|
|
394
|
-
} else {
|
|
456
|
+
} else if (dictTagsMatchL3) {
|
|
395
457
|
/* check dict long +1 match */
|
|
396
|
-
U32 const dictMatchIndexL3 =
|
|
458
|
+
U32 const dictMatchIndexL3 = dictMatchIndexAndTagL3 >> ZSTD_SHORT_CACHE_TAG_BITS;
|
|
397
459
|
const BYTE* dictMatchL3 = dictBase + dictMatchIndexL3;
|
|
398
460
|
assert(dictMatchL3 < dictEnd);
|
|
399
461
|
if (dictMatchL3 > dictStart && MEM_read64(dictMatchL3) == MEM_read64(ip+1)) {
|
|
@@ -419,7 +481,7 @@ _match_found:
|
|
|
419
481
|
offset_2 = offset_1;
|
|
420
482
|
offset_1 = offset;
|
|
421
483
|
|
|
422
|
-
ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend,
|
|
484
|
+
ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend, OFFSET_TO_OFFBASE(offset), mLength);
|
|
423
485
|
|
|
424
486
|
_match_stored:
|
|
425
487
|
/* match found */
|
|
@@ -448,7 +510,7 @@ _match_stored:
|
|
|
448
510
|
const BYTE* const repEnd2 = repIndex2 < prefixLowestIndex ? dictEnd : iend;
|
|
449
511
|
size_t const repLength2 = ZSTD_count_2segments(ip+4, repMatch2+4, iend, repEnd2, prefixLowest) + 4;
|
|
450
512
|
U32 tmpOffset = offset_2; offset_2 = offset_1; offset_1 = tmpOffset; /* swap offset_2 <=> offset_1 */
|
|
451
|
-
ZSTD_storeSeq(seqStore, 0, anchor, iend,
|
|
513
|
+
ZSTD_storeSeq(seqStore, 0, anchor, iend, REPCODE1_TO_OFFBASE, repLength2);
|
|
452
514
|
hashSmall[ZSTD_hashPtr(ip, hBitsS, mls)] = current2;
|
|
453
515
|
hashLong[ZSTD_hashPtr(ip, hBitsL, 8)] = current2;
|
|
454
516
|
ip += repLength2;
|
|
@@ -461,8 +523,8 @@ _match_stored:
|
|
|
461
523
|
} /* while (ip < ilimit) */
|
|
462
524
|
|
|
463
525
|
/* save reps for next block */
|
|
464
|
-
rep[0] = offset_1
|
|
465
|
-
rep[1] = offset_2
|
|
526
|
+
rep[0] = offset_1;
|
|
527
|
+
rep[1] = offset_2;
|
|
466
528
|
|
|
467
529
|
/* Return the last literals size */
|
|
468
530
|
return (size_t)(iend - anchor);
|
|
@@ -585,7 +647,7 @@ static size_t ZSTD_compressBlock_doubleFast_extDict_generic(
|
|
|
585
647
|
const BYTE* repMatchEnd = repIndex < prefixStartIndex ? dictEnd : iend;
|
|
586
648
|
mLength = ZSTD_count_2segments(ip+1+4, repMatch+4, iend, repMatchEnd, prefixStart) + 4;
|
|
587
649
|
ip++;
|
|
588
|
-
ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend,
|
|
650
|
+
ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend, REPCODE1_TO_OFFBASE, mLength);
|
|
589
651
|
} else {
|
|
590
652
|
if ((matchLongIndex > dictStartIndex) && (MEM_read64(matchLong) == MEM_read64(ip))) {
|
|
591
653
|
const BYTE* const matchEnd = matchLongIndex < prefixStartIndex ? dictEnd : iend;
|
|
@@ -596,7 +658,7 @@ static size_t ZSTD_compressBlock_doubleFast_extDict_generic(
|
|
|
596
658
|
while (((ip>anchor) & (matchLong>lowMatchPtr)) && (ip[-1] == matchLong[-1])) { ip--; matchLong--; mLength++; } /* catch up */
|
|
597
659
|
offset_2 = offset_1;
|
|
598
660
|
offset_1 = offset;
|
|
599
|
-
ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend,
|
|
661
|
+
ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend, OFFSET_TO_OFFBASE(offset), mLength);
|
|
600
662
|
|
|
601
663
|
} else if ((matchIndex > dictStartIndex) && (MEM_read32(match) == MEM_read32(ip))) {
|
|
602
664
|
size_t const h3 = ZSTD_hashPtr(ip+1, hBitsL, 8);
|
|
@@ -621,7 +683,7 @@ static size_t ZSTD_compressBlock_doubleFast_extDict_generic(
|
|
|
621
683
|
}
|
|
622
684
|
offset_2 = offset_1;
|
|
623
685
|
offset_1 = offset;
|
|
624
|
-
ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend,
|
|
686
|
+
ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend, OFFSET_TO_OFFBASE(offset), mLength);
|
|
625
687
|
|
|
626
688
|
} else {
|
|
627
689
|
ip += ((ip-anchor) >> kSearchStrength) + 1;
|
|
@@ -653,7 +715,7 @@ static size_t ZSTD_compressBlock_doubleFast_extDict_generic(
|
|
|
653
715
|
const BYTE* const repEnd2 = repIndex2 < prefixStartIndex ? dictEnd : iend;
|
|
654
716
|
size_t const repLength2 = ZSTD_count_2segments(ip+4, repMatch2+4, iend, repEnd2, prefixStart) + 4;
|
|
655
717
|
U32 const tmpOffset = offset_2; offset_2 = offset_1; offset_1 = tmpOffset; /* swap offset_2 <=> offset_1 */
|
|
656
|
-
ZSTD_storeSeq(seqStore, 0, anchor, iend,
|
|
718
|
+
ZSTD_storeSeq(seqStore, 0, anchor, iend, REPCODE1_TO_OFFBASE, repLength2);
|
|
657
719
|
hashSmall[ZSTD_hashPtr(ip, hBitsS, mls)] = current2;
|
|
658
720
|
hashLong[ZSTD_hashPtr(ip, hBitsL, 8)] = current2;
|
|
659
721
|
ip += repLength2;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under both the BSD-style license (found in the
|
|
@@ -19,7 +19,8 @@ extern "C" {
|
|
|
19
19
|
#include "zstd_compress_internal.h" /* ZSTD_CCtx, size_t */
|
|
20
20
|
|
|
21
21
|
void ZSTD_fillDoubleHashTable(ZSTD_matchState_t* ms,
|
|
22
|
-
void const* end, ZSTD_dictTableLoadMethod_e dtlm
|
|
22
|
+
void const* end, ZSTD_dictTableLoadMethod_e dtlm,
|
|
23
|
+
ZSTD_tableFillPurpose_e tfp);
|
|
23
24
|
size_t ZSTD_compressBlock_doubleFast(
|
|
24
25
|
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
|
25
26
|
void const* src, size_t srcSize);
|