From: bimbashrestha Date: Mon, 26 Aug 2019 15:51:34 +0000 (-0700) Subject: Removing implicit conversion from const void* to const BYTE* and added constant for... X-Git-Tag: v1.4.4~1^2~65^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba469324927a0c205a6756d307b0436fc101112c;p=thirdparty%2Fzstd.git Removing implicit conversion from const void* to const BYTE* and added constant for threshold --- diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 6e02da4f0..7ea929aff 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -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