From: Yann Collet Date: Tue, 29 Nov 2016 02:38:52 +0000 (-0800) Subject: combined normal and long decoder X-Git-Tag: v1.1.2~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce3527ca0c11bce66b5d64d36a3f1f0355d4c10c;p=thirdparty%2Fzstd.git combined normal and long decoder --- diff --git a/lib/decompress/zstd_decompress.c b/lib/decompress/zstd_decompress.c index d96dd7841..2d4087335 100644 --- a/lib/decompress/zstd_decompress.c +++ b/lib/decompress/zstd_decompress.c @@ -56,6 +56,15 @@ #endif +#if defined(_MSC_VER) +# include /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */ +# define ZSTD_PREFETCH(ptr) _mm_prefetch(ptr, _MM_HINT_T0) +#elif defined(__GNUC__) +# define ZSTD_PREFETCH(ptr) __builtin_prefetch(ptr, 0, 0) +#else +# define ZSTD_PREFETCH(ptr) /* disabled */ +#endif + /*-************************************* * Macros ***************************************/ @@ -997,7 +1006,6 @@ size_t ZSTD_execSequenceLong(BYTE* op, } -#define ZSTD_PREFETCH(ptr) __builtin_prefetch(ptr, 0, 0); static size_t ZSTD_decompressSequencesLong( ZSTD_DCtx* dctx, void* dst, size_t maxDstSize, @@ -1023,9 +1031,9 @@ static size_t ZSTD_decompressSequencesLong( /* Regen sequences */ if (nbSeq) { -#define STORED_SEQS 8 +#define STORED_SEQS 4 #define STOSEQ_MASK (STORED_SEQS-1) -#define ADVANCED_SEQS 5 +#define ADVANCED_SEQS 4 seq_t sequences[STORED_SEQS]; int const seqAdvance = MIN(nbSeq, ADVANCED_SEQS); seqState_t seqState; @@ -1315,6 +1323,8 @@ static size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx, ip += litCSize; srcSize -= litCSize; } + if (dctx->fParams.windowSize > 23) + return ZSTD_decompressSequencesLong(dctx, dst, dstCapacity, ip, srcSize); return ZSTD_decompressSequences(dctx, dst, dstCapacity, ip, srcSize); }