]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Removing implicit conversion from const void* to const BYTE* and added constant for...
authorbimbashrestha <bshrestha.msae@gmail.com>
Mon, 26 Aug 2019 15:51:34 +0000 (08:51 -0700)
committerbimbashrestha <bshrestha.msae@gmail.com>
Mon, 26 Aug 2019 15:51:34 +0000 (08:51 -0700)
lib/compress/zstd_compress.c

index 6e02da4f03c3326ba588ab88d4f72bc52ce4d7d7..7ea929aff1ab7ab7031d317f8d7ecbb4321fc7d6 100644 (file)
@@ -2278,6 +2278,12 @@ static size_t ZSTD_compressBlock_internal(ZSTD_CCtx* zc,
                                         void* dst, size_t dstCapacity,
                                         const void* src, size_t srcSize)
 {
+    /*
+        This the upper bound for the length of an rle block.
+        This isn't the actual upper bound. Finding the real threshold
+        needs further investigation.
+    */
+    const int rleMaxLength = 25;
     size_t cSize;
     const BYTE* ip = (const BYTE*)src;
     BYTE* op = (BYTE*)dst;
@@ -2299,7 +2305,7 @@ static size_t ZSTD_compressBlock_internal(ZSTD_CCtx* zc,
             zc->entropyWorkspace, HUF_WORKSPACE_SIZE /* statically allocated in resetCCtx */,
             zc->bmi2);
 
-    if (cSize < 10 && ZSTD_isRLE(ip, srcSize)) {
+    if (cSize < rleMaxLength && ZSTD_isRLE(ip, srcSize)) {
         cSize = 1;
         op[0] = ip[0];
     }
@@ -2311,7 +2317,7 @@ out:
         zc->blockState.prevCBlock = zc->blockState.nextCBlock;
         zc->blockState.nextCBlock = tmp;
 
-        assert(!ZSTD_isRLE(src, srcSize));
+        assert(!ZSTD_isRLE(ip, srcSize));
     }
     /* We check that dictionaries have offset codes available for the first
      * block. After the first block, the offcode table might not have large