]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Improve documentation of seqStore_t
authorsenhuang42 <senhuang96@fb.com>
Tue, 27 Oct 2020 14:43:37 +0000 (10:43 -0400)
committersenhuang42 <senhuang96@fb.com>
Tue, 27 Oct 2020 14:50:22 +0000 (10:50 -0400)
lib/common/zstd_internal.h
lib/compress/zstd_compress.c
lib/zstd.h

index bfa98efaaf45f41f82c1e131ec2766faf31f6663..f9972766dee0ed06a150962efeab282113d4f5ee 100644 (file)
@@ -341,23 +341,28 @@ MEM_STATIC size_t ZSTD_limitCopy(void* dst, size_t dstCapacity, const void* src,
 *  Private declarations
 *********************************************/
 typedef struct seqDef_s {
-    U32 offset;
+    U32 offset;         /* Offset code of the sequence */
     U16 litLength;
     U16 matchLength;
 } seqDef;
 
 typedef struct {
     seqDef* sequencesStart;
-    seqDef* sequences;
+    seqDef* sequences;      /* ptr to end of sequences */
     BYTE* litStart;
-    BYTE* lit;
+    BYTE* lit;              /* ptr to end of literals */
     BYTE* llCode;
     BYTE* mlCode;
     BYTE* ofCode;
     size_t maxNbSeq;
     size_t maxNbLit;
-    U32   longLengthID;   /* 0 == no longLength; 1 == Lit.longLength; 2 == Match.longLength; */
-    U32   longLengthPos;
+
+    /* longLengthPos and longLengthID to allow us to represent either a single litLength or matchLength
+     * in the seqStore that has a value larger than U16 (if it exists). To do so, we increment
+     * the existing value of the literal or match by 0x10000. 
+     */
+    U32   longLengthID;   /* 0 == no longLength; 1 == Represent the long literal; 2 == Represent the long match; */
+    U32   longLengthPos;  /* Index of the sequence to apply long length modification to */
 } seqStore_t;
 
 typedef struct {
index b3ada04f45ba5cf153e19fd70e2b2c745462f19c..9d5f20a61c8e9e334823cb072d9e41dfd9420b00 100644 (file)
@@ -2455,10 +2455,6 @@ static void ZSTD_copyBlockSequences(ZSTD_CCtx* zc)
         outSeqs[i].litLength = seqStoreSeqs[i].litLength;
         outSeqs[i].matchLength = seqStoreSeqs[i].matchLength + MINMATCH;
 
-        /* matchLength and litLength are stored with U16. longLengthPos
-         * and longLengthID to allow us to represent a single litLength or matchLength
-         * in the seqStore that has a value larger than U16 (if it exists).
-         */
         if (i == seqStore->longLengthPos) {
             if (seqStore->longLengthID == 1) {
                 outSeqs[i].litLength += 0x10000;
index 7668729a1e7c30415343d1b75fb98471ed739138..1c61bd001f9bd0dafc9d4ad07a05561dc3d730c3 100644 (file)
@@ -1115,24 +1115,24 @@ typedef struct ZSTD_CCtx_params_s ZSTD_CCtx_params;
 
 typedef struct {
     unsigned int offset;      /* The offset of the match.
-                              * If == 0, then represents a block of literals, determined by litLength
-                              */
+                               * If == 0, then represents a block of literals, determined by litLength
+                               */
 
     unsigned int litLength;   /* Literal length */
     unsigned int matchLength; /* Match length. */
     
     unsigned int rep;         /* Represents which repeat offset is used. Ranges from [0, 3].
-                              * If rep == 0, then this sequence does not contain a repeat offset.
-                              * Otherwise:
-                              *  If litLength != 0:
-                              *      rep == 1 --> offset == repeat offset 1
-                              *      rep == 2 --> offset == repeat offset 2
-                              *      rep == 3 --> offset == repeat offset 3
-                              *  If litLength == 0:
-                              *      rep == 1 --> offset == repeat offset 2
-                              *      rep == 2 --> offset == repeat offset 3
-                              *      rep == 3 --> offset == repeat offset 1 - 1
-                              */
+                               * If rep == 0, then this sequence does not contain a repeat offset.
+                               * Otherwise:
+                               *  If litLength != 0:
+                               *      rep == 1 --> offset == repeat offset 1
+                               *      rep == 2 --> offset == repeat offset 2
+                               *      rep == 3 --> offset == repeat offset 3
+                               *  If litLength == 0:
+                               *      rep == 1 --> offset == repeat offset 2
+                               *      rep == 2 --> offset == repeat offset 3
+                               *      rep == 3 --> offset == repeat offset 1 - 1
+                               */
 } ZSTD_Sequence;
 
 typedef struct {