]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
minor reordering (DSpeed 665)
authorYann Collet <yann.collet.73@gmail.com>
Wed, 23 Mar 2016 13:00:09 +0000 (14:00 +0100)
committerYann Collet <yann.collet.73@gmail.com>
Wed, 23 Mar 2016 13:00:09 +0000 (14:00 +0100)
lib/zstd_compress.c
lib/zstd_decompress.c

index 5ae6d37df0e79b4bcc676e49d796ca4c4b7ae649..e2d42fafe066279a88ce88f2fe55120fd18ed2e0 100644 (file)
@@ -742,9 +742,9 @@ size_t ZSTD_compressSequences(ZSTD_CCtx* zc,
         FSE_initCState2(&stateMatchLength, CTable_MatchLength, mlCodeTable[nbSeq-1]);
         FSE_initCState2(&stateOffsetBits,  CTable_OffsetBits,  offCodeTable[nbSeq-1]);
         FSE_initCState2(&stateLitLength,   CTable_LitLength,   llCodeTable[nbSeq-1]);
-        BIT_addBits(&blockStream, offsetTable[nbSeq-1], offCodeTable[nbSeq-1] ? (offCodeTable[nbSeq-1]-1) : 0);
-        BIT_addBits(&blockStream, mlTable[nbSeq-1], ML_bits[mlCodeTable[nbSeq-1]]);
         BIT_addBits(&blockStream, llTable[nbSeq-1], LL_bits[llCodeTable[nbSeq-1]]);
+        BIT_addBits(&blockStream, mlTable[nbSeq-1], ML_bits[mlCodeTable[nbSeq-1]]);
+        BIT_addBits(&blockStream, offsetTable[nbSeq-1], offCodeTable[nbSeq-1] ? (offCodeTable[nbSeq-1]-1) : 0);
         BIT_flushBits(&blockStream);
 
         {   size_t n;
@@ -758,9 +758,9 @@ size_t ZSTD_compressSequences(ZSTD_CCtx* zc,
                 FSE_encodeSymbol(&blockStream, &stateOffsetBits, offCode);      /* 25 */  /* 35 */
                 FSE_encodeSymbol(&blockStream, &stateMatchLength, MLCode);      /* 17 */  /* 17 */
                 FSE_encodeSymbol(&blockStream, &stateLitLength, LLCode);        /* 16 */  /* 26 */
-                BIT_addBits(&blockStream, offset, nbBits);                      /* 31 */  /* 61 */   /* 24 bits max in 32-bits mode */
-                BIT_addBits(&blockStream, mlTable[n], ML_bits[MLCode]);
                 BIT_addBits(&blockStream, llTable[n], LL_bits[LLCode]);
+                BIT_addBits(&blockStream, mlTable[n], ML_bits[MLCode]);
+                BIT_addBits(&blockStream, offset, nbBits);                      /* 31 */  /* 61 */   /* 24 bits max in 32-bits mode */
                 BIT_flushBits(&blockStream);                                    /*  7 */  /*  7 */
         }   }
 
index 92af2b35d2c5389e82a5ab94027895ee1bfa55a6..1de3da1e03d177ccb93e350c8ce7b59c317655b1 100644 (file)
@@ -635,6 +635,8 @@ static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState, const U32 mls)
     U32 const mlBits = ML_bits[mlCode];
     U32 const ofBits = ofCode ? ofCode-1 : 0;
 
+    size_t allBits = BIT_readBits(&(seqState->DStream), llBits+mlBits+ofBits);
+
     static const U32 LL_base[MaxLL+1] = {
                              0,  1,  2,  3,  4,  5,  6,  7,  8,  9,   10,    11,    12,    13,    14,     15,
                             16, 18, 20, 22, 24, 28, 32, 40, 48, 64, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000,
@@ -652,18 +654,15 @@ static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState, const U32 mls)
                 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000,
                 0x800000, 0x1000000, 0x2000000, 0x4000000, /*fake*/ 1, 1, 1, 1 };
 
-    size_t allBits = BIT_readBits(&(seqState->DStream), llBits+mlBits+ofBits);
-
-    /* Offset */
+    /* sequence */
+    seq->litLength = LL_base[llCode] + BIT_consumeFirstBits(&allBits, llBits);
+    seq->matchLength = ML_base[mlCode] + BIT_consumeFirstBits(&allBits, mlBits) + mls;
     {   size_t const offset = ofCode ? OF_base[ofCode] + BIT_consumeFirstBits(&allBits, ofBits) :
                                        llCode ? seq->offset : seqState->prevOffset;
         if (ofCode | !llCode) seqState->prevOffset = seq->offset;   /* cmove */
         seq->offset = offset;
     }
 
-    seq->matchLength = ML_base[mlCode] + BIT_consumeFirstBits(&allBits, mlBits) + mls;
-    seq->litLength = LL_base[llCode] + BIT_consumeFirstBits(&allBits, llBits);
-
     /* ANS state update */
     FSE_updateState(&(seqState->stateLL), &(seqState->DStream));
     FSE_updateState(&(seqState->stateML), &(seqState->DStream));