mirror of
https://github.com/cuberite/libdeflate.git
synced 2025-09-21 02:11:43 -04:00

Improve libdeflate's worst-case performance decompressing malicious DEFLATE streams by about 14x, bringing it within a factor of about 2x of zlib, by skipping rebuilding the decode tables for the static Huffman codes when they're already loaded into the decompressor. This improves performance decompressing a stream of all empty static Huffman blocks from about 0.36 MB/s to 175 MB/s, or the original reproducer given on the Github issue from about 3.3 MB/s to 219 MB/s. A regression test is added for these cases as well as the empty dynamic Huffman blocks case to verify worst-case performance comparable to zlib. Resolves https://github.com/ebiggers/libdeflate/issues/33