GZipOutputStream level 4 compresses less well (but faster) than level 3
Steps to reproduce
- Compress a file with GZipOutputStream, calling SetLevel(4)
- Compress the same file with GZipOutputStream, calling SetLevel(3)
Expected behavior
The file compressed with SetLevel(4) should usually be smaller than SetLevel(3).
Actual behavior
The file compressed with SetLevel(4) is usually larger than with SetLevel(3).
Version of SharpZipLib
0.86.0.518
Obtained from (place an x between the brackets for all that apply)
- Package installed using:
- NuGet
The settings for level 4 in DeflaterConstants.cs are the same as in zlib, except for the compression function to use. In zlib, level 4 uses the deflateSlow function. DeflaterConstants has COMPR_FUNC[4] set to 1, which is DEFLATE_FAST. The other constants, MAX_LAZY, NICE_LENGTH and MAX_CHAIN are smaller for level 4 than for level 3, leading to worse compression in general.
I have not looked in to why certain constants where used for each level. One would assume that they should be the same as in zlib.
A PR would be welcomed!