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

Use lookup tables safely #36

Closed Shnatsel closed 5 years ago

Shnatsel commented 5 years ago

Use regular indexing operations for lookup tables instead of get_unchecked(). This regresses performance by 0.7% - decoding enwiki-latest-all-titles-in-ns0.gz goes from 2,160s to 2,175s on my machine, as measured with hyperfine: hyperfine -m 25 --warmup=3 'target/release/examples/flate -i enwiki-latest-all-titles-in-ns0.gz -o /dev/null gzip-decode'

Since the main selling point of a Rust implementation is safety, I don't think using unsafe for less than 1% speedup is justified.

codecov-io commented 5 years ago

Codecov Report

Merging #36 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #36   +/-   ##
=======================================
  Coverage   91.46%   91.46%           
=======================================
  Files          14       14           
  Lines        1301     1301           
=======================================
  Hits         1190     1190           
  Misses        111      111
Impacted Files Coverage Δ
src/deflate/symbol.rs 93.06% <100%> (ø) :arrow_up:
src/lz77/default.rs 89.1% <100%> (ø) :arrow_up:
src/huffman.rs 94.02% <100%> (ø) :arrow_up:

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 cbf1289...659ffd8. Read the comment docs.