reordered code
This commit is contained in:
+28
-29
@@ -1251,28 +1251,6 @@ static void ZSTD_compressBlock_fast_extDict(ZSTD_CCtx* ctx,
|
|||||||
|
|
||||||
#define NEXT_IN_CHAIN(d, mask) chainTable[(d) & mask]
|
#define NEXT_IN_CHAIN(d, mask) chainTable[(d) & mask]
|
||||||
|
|
||||||
|
|
||||||
/* Update hashTable3 up to ip (excluded)
|
|
||||||
Assumption : always within prefix (ie. not within extDict) */
|
|
||||||
FORCE_INLINE
|
|
||||||
U32 ZSTD_insertAndFindFirstIndexHash3 (ZSTD_CCtx* zc, const BYTE* ip)
|
|
||||||
{
|
|
||||||
U32* const hashTable3 = zc->hashTable3;
|
|
||||||
U32 const hashLog3 = zc->hashLog3;
|
|
||||||
const BYTE* const base = zc->base;
|
|
||||||
const U32 target = (U32)(ip - base);
|
|
||||||
U32 idx = zc->nextToUpdate3;
|
|
||||||
|
|
||||||
while(idx < target) {
|
|
||||||
hashTable3[ZSTD_hash3Ptr(base+idx, hashLog3)] = idx;
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
zc->nextToUpdate3 = target;
|
|
||||||
return hashTable3[ZSTD_hash3Ptr(ip, hashLog3)];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Update chains up to ip (excluded)
|
/* Update chains up to ip (excluded)
|
||||||
Assumption : always within prefix (ie. not within extDict) */
|
Assumption : always within prefix (ie. not within extDict) */
|
||||||
FORCE_INLINE
|
FORCE_INLINE
|
||||||
@@ -1298,6 +1276,27 @@ U32 ZSTD_insertAndFindFirstIndex (ZSTD_CCtx* zc, const BYTE* ip, U32 mls)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Update hashTable3 up to ip (excluded)
|
||||||
|
Assumption : always within prefix (ie. not within extDict) */
|
||||||
|
FORCE_INLINE
|
||||||
|
U32 ZSTD_insertAndFindFirstIndexHash3 (ZSTD_CCtx* zc, const BYTE* ip)
|
||||||
|
{
|
||||||
|
U32* const hashTable3 = zc->hashTable3;
|
||||||
|
U32 const hashLog3 = zc->hashLog3;
|
||||||
|
const BYTE* const base = zc->base;
|
||||||
|
U32 idx = zc->nextToUpdate3;
|
||||||
|
const U32 target = zc->nextToUpdate3 = (U32)(ip - base);
|
||||||
|
const size_t hash3 = ZSTD_hash3Ptr(ip, hashLog3);
|
||||||
|
|
||||||
|
while(idx < target) {
|
||||||
|
hashTable3[ZSTD_hash3Ptr(base+idx, hashLog3)] = idx;
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hashTable3[hash3];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FORCE_INLINE /* inlining is important to hardwire a hot branch (template emulation) */
|
FORCE_INLINE /* inlining is important to hardwire a hot branch (template emulation) */
|
||||||
size_t ZSTD_HcFindBestMatch_generic (
|
size_t ZSTD_HcFindBestMatch_generic (
|
||||||
ZSTD_CCtx* zc, /* Index table will be updated */
|
ZSTD_CCtx* zc, /* Index table will be updated */
|
||||||
@@ -1321,22 +1320,22 @@ size_t ZSTD_HcFindBestMatch_generic (
|
|||||||
size_t ml=minMatch-1;
|
size_t ml=minMatch-1;
|
||||||
|
|
||||||
if (minMatch == 3) { /* HC3 match finder */
|
if (minMatch == 3) { /* HC3 match finder */
|
||||||
matchIndex = ZSTD_insertAndFindFirstIndexHash3 (zc, ip);
|
U32 const matchIndex3 = ZSTD_insertAndFindFirstIndexHash3 (zc, ip);
|
||||||
if (matchIndex>lowLimit && current - matchIndex<(1<<18)) {
|
if (matchIndex3>lowLimit && current - matchIndex3<(1<<18)) {
|
||||||
const BYTE* match;
|
const BYTE* match;
|
||||||
size_t currentMl=0;
|
size_t currentMl=0;
|
||||||
if ((!extDict) || matchIndex >= dictLimit) {
|
if ((!extDict) || matchIndex3 >= dictLimit) {
|
||||||
match = base + matchIndex;
|
match = base + matchIndex3;
|
||||||
if (match[ml] == ip[ml]) /* potentially better */
|
if (match[ml] == ip[ml]) /* potentially better */
|
||||||
currentMl = ZSTD_count(ip, match, iLimit);
|
currentMl = ZSTD_count(ip, match, iLimit);
|
||||||
} else {
|
} else {
|
||||||
match = dictBase + matchIndex;
|
match = dictBase + matchIndex3;
|
||||||
if (MEM_readMINMATCH(match, MINMATCH) == MEM_readMINMATCH(ip, MINMATCH)) /* assumption : matchIndex <= dictLimit-4 (by table construction) */
|
if (MEM_readMINMATCH(match, MINMATCH) == MEM_readMINMATCH(ip, MINMATCH)) /* assumption : matchIndex3 <= dictLimit-4 (by table construction) */
|
||||||
currentMl = ZSTD_count_2segments(ip+MINMATCH, match+MINMATCH, iLimit, dictEnd, prefixStart) + MINMATCH;
|
currentMl = ZSTD_count_2segments(ip+MINMATCH, match+MINMATCH, iLimit, dictEnd, prefixStart) + MINMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save best solution */
|
/* save best solution */
|
||||||
if (currentMl > ml) { ml = currentMl; *offsetPtr = ZSTD_REP_MOVE + current - matchIndex; if (ip+currentMl == iLimit) return (ml>=MINMATCH) ? ml : 0; /* best possible, and avoid read overflow*/ }
|
if (currentMl > ml) { ml = currentMl; *offsetPtr = ZSTD_REP_MOVE + current - matchIndex3; if (ip+currentMl == iLimit) return (ml>=MINMATCH) ? ml : 0; /* best possible, and avoid read overflow*/ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ BINDIR = $(PREFIX)/bin
|
|||||||
MANDIR = $(PREFIX)/share/man/man1
|
MANDIR = $(PREFIX)/share/man/man1
|
||||||
ZSTDDIR = ../lib
|
ZSTDDIR = ../lib
|
||||||
|
|
||||||
ZSTD_FILES := $(ZSTDDIR)/huff0.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/zstd_compress.c $(ZSTDDIR)/zstd_decompress.c
|
ZSTD_FILES := $(ZSTDDIR)/huff0.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/zstd_decompress.c $(ZSTDDIR)/zstd_compress.c
|
||||||
|
|
||||||
ifeq ($(ZSTD_LEGACY_SUPPORT), 0)
|
ifeq ($(ZSTD_LEGACY_SUPPORT), 0)
|
||||||
CPPFLAGS += -DZSTD_LEGACY_SUPPORT=0
|
CPPFLAGS += -DZSTD_LEGACY_SUPPORT=0
|
||||||
|
|||||||
Reference in New Issue
Block a user