code simplification (but reduce decompression speed ...)

This commit is contained in:
Yann Collet
2016-03-21 13:24:16 +01:00
parent 5c71491a46
commit b0aec17a90
5 changed files with 113 additions and 128 deletions
+8 -8
View File
@@ -31,7 +31,7 @@
- Zstd source repository : https://www.zstd.net
*/
/* Note : this file is intended to be included within zstd_compress.c */
/* Note : this file is intended to be included within zstd_compress.c */
#define ZSTD_FREQ_DIV 5
@@ -55,7 +55,7 @@ MEM_STATIC void ZSTD_rescaleFreqs(seqStore_t* ssPtr)
if (ssPtr->litLengthSum == 0) {
ssPtr->litSum = (2<<Litbits);
ssPtr->litLengthSum = (1<<LLbits);
ssPtr->litLengthSum = MaxLL+1;
ssPtr->matchLengthSum = (1<<MLbits);
ssPtr->offCodeSum = (1<<Offbits);
ssPtr->matchSum = (2<<Litbits);
@@ -93,7 +93,7 @@ MEM_STATIC void ZSTD_rescaleFreqs(seqStore_t* ssPtr)
ssPtr->offCodeSum += ssPtr->offCodeFreq[u];
}
}
ZSTD_setLog2Prices(ssPtr);
}
@@ -243,7 +243,7 @@ static U32 ZSTD_insertBtAndGetAllMatches (
if (minMatch == 3) { /* HC3 match finder */
U32 matchIndex3 = ZSTD_insertAndFindFirstIndexHash3 (zc, ip);
if (matchIndex3>windowLow && (current - matchIndex3 < (1<<18))) {
const BYTE* match;
size_t currentMl=0;
@@ -408,7 +408,7 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
const BYTE* const ilimit = iend - 8;
const BYTE* const base = ctx->base;
const BYTE* const prefixStart = base + ctx->dictLimit;
U32 rep_2=REPCODE_STARTVALUE, rep_1=REPCODE_STARTVALUE;
const U32 maxSearches = 1U << ctx->params.searchLog;
const U32 sufficient_len = ctx->params.targetLength;
@@ -733,7 +733,7 @@ void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx* ctx,
const BYTE* const dictBase = ctx->dictBase;
const BYTE* const dictEnd = dictBase + dictLimit;
const U32 lowLimit = ctx->lowLimit;
U32 rep_2=REPCODE_STARTVALUE, rep_1=REPCODE_STARTVALUE;
const U32 maxSearches = 1U << ctx->params.searchLog;
const U32 sufficient_len = ctx->params.targetLength;
@@ -1044,12 +1044,12 @@ _storeSequence: // cur, last_pos, best_mlen, best_off have to be set
break;
} else {
const BYTE* repMatch = dictBase + ((anchor-base) - rep_2);
if ((repMatch + minMatch <= dictEnd) && (MEM_readMINMATCH(anchor, minMatch) == MEM_readMINMATCH(repMatch, minMatch)))
if ((repMatch + minMatch <= dictEnd) && (MEM_readMINMATCH(anchor, minMatch) == MEM_readMINMATCH(repMatch, minMatch)))
mlen = (U32)ZSTD_count_2segments(anchor+minMatch, repMatch+minMatch, iend, dictEnd, prefixStart) + minMatch;
else
break;
}
offset = rep_2; rep_2 = rep_1; rep_1 = offset; /* swap offset history */
ZSTD_LOG_ENCODE("%d/%d: ENCODE REP literals=%d mlen=%d off=%d rep1=%d rep2=%d\n", (int)(anchor-base), (int)(iend-base), (int)(0), (int)best_mlen, (int)(0), (int)rep_1, (int)rep_2);
ZSTD_updatePrice(seqStorePtr, 0, anchor, 0, mlen-minMatch);