diff --git a/lib/decompress/zstd_decompress.c b/lib/decompress/zstd_decompress.c index cc92ca27..1890a853 100644 --- a/lib/decompress/zstd_decompress.c +++ b/lib/decompress/zstd_decompress.c @@ -1013,7 +1013,9 @@ static size_t ZSTD_decompressSequences( /* Regen sequences */ if (nbSeq) { + seq_t sequences[4]; seqState_t seqState; + int seqNb; dctx->fseEntropy = 1; { U32 i; for (i=0; irep[i]; } CHECK_E(BIT_initDStream(&seqState.DStream, ip, iend-ip), corruption_detected); @@ -1021,16 +1023,31 @@ static size_t ZSTD_decompressSequences( FSE_initDState(&seqState.stateOffb, &seqState.DStream, dctx->OFTptr); FSE_initDState(&seqState.stateML, &seqState.DStream, dctx->MLTptr); - for ( ; (BIT_reloadDStream(&(seqState.DStream)) <= BIT_DStream_completed) && nbSeq ; ) { - nbSeq--; - { seq_t const sequence = ZSTD_decodeSequence(&seqState); - size_t const oneSeqSize = ZSTD_execSequence(op, oend, sequence, &litPtr, litEnd, base, vBase, dictEnd); + /* prepare in advance */ + int const seqAdvance = MIN(nbSeq, 3); + for (seqNb=0; (BIT_reloadDStream(&(seqState.DStream)) <= BIT_DStream_completed) && seqNbrep[i] = (U32)(seqState.prevOffset[i]); } }