lz4hc.c: clamp compression levels > 12

I noticed that, while 'lz4 -12' works fine, 'lz4 -13' does not compress
at all.

$ cat </etc/passwd |wc -c
2565
$ lz4 -12 </etc/passwd |wc -c
1456
$ lz4 -13 </etc/passwd |wc -c
2584

Perhaps the best way to fix this is to clamp the compression level
in the LZ4HC_compress_generic routine.
This commit is contained in:
Alexey Tourbin 2017-04-29 15:52:51 +03:00
parent a41df535f7
commit 6cf1f7d758

View File

@ -555,6 +555,8 @@ static int LZ4HC_compress_generic (
ctx->searchNum = LZ4HC_getSearchNum(cLevel); ctx->searchNum = LZ4HC_getSearchNum(cLevel);
return LZ4HC_compress_optimal(ctx, src, dst, *srcSizePtr, dstCapacity, limit, 128, 0); return LZ4HC_compress_optimal(ctx, src, dst, *srcSizePtr, dstCapacity, limit, 128, 0);
default: default:
cLevel = 12;
/* pass-through */
case 12: case 12:
ctx->searchNum = LZ4HC_getSearchNum(cLevel); ctx->searchNum = LZ4HC_getSearchNum(cLevel);
return LZ4HC_compress_optimal(ctx, src, dst, *srcSizePtr, dstCapacity, limit, LZ4_OPT_NUM, 1); return LZ4HC_compress_optimal(ctx, src, dst, *srcSizePtr, dstCapacity, limit, LZ4_OPT_NUM, 1);