sile / libflate

A Rust implementation of DEFLATE algorithm and related formats (ZLIB, GZIP)
https://docs.rs/libflate
MIT License
178 stars 35 forks source link

Make max share length in lz77 configurable #48

Closed HybridEidolon closed 4 years ago

HybridEidolon commented 4 years ago

Certain erroneous implementations of LZ77 have encodings that can't encode pointer shares of the standard maximum copy length of 258. In the linked example's case, for older iterations it can only copy up to 256 bytes in a single command. I figure that this may have been a performance optimization back in the 1990s, since newer games using this particular encoding have been fixed (though they still only support a window size of 8k).

This PR adds a Builder type to configure both the MAX_LENGTH constant and the already-configurable window size in the default compressor implementation, and changes existing constructor paths to use that builder. It is backwards-compatible with existing code. There may be a slight performance loss as a result under all paths, but nothing significant.

codecov-io commented 4 years ago

Codecov Report

Merging #48 into master will decrease coverage by 0.69%. The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #48     +/-   ##
=========================================
- Coverage   85.37%   84.67%   -0.7%     
=========================================
  Files          19       19             
  Lines        2119     2147     +28     
=========================================
+ Hits         1809     1818      +9     
- Misses        310      329     +19
Impacted Files Coverage Δ
libflate_lz77/src/lib.rs 100% <ø> (ø) :arrow_up:
libflate_lz77/src/default.rs 74.57% <50%> (-13.21%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 105176a...d1d872c. Read the comment docs.

sile commented 4 years ago

Published: https://crates.io/crates/libflate_lz77/0.1.1