Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add const implementation for build_huff_lut #1326

Merged
merged 5 commits into from
Oct 2, 2021

Conversation

HeroicKatora
Copy link
Member

This PR adds a const implementation of derive_codes_and_sizes and build_huff_lut - as these functions are typically used on const data - this speeds up JpegEncoder::new / JpegEncoder::new_with_quality by 4x (2250ns -> 500ns), but this is only really significant if you're making many, many small images and creating new encoders for each.

This isn't currently compatible without using nightly on 1.34, but it does compile without nightly on 1.46, so merging this PR would require a bump in the minimum version required.

This is a resubmit of #1324 which was auto-closed as its commits were a subset of #1322 ..

cc: @philippeitis

Since the Huffman LUT in JpegEncoder are constant, they're a good candidate for a const_fn that makes them evaluable at compile-time. This helps make JpegEncoder::new() / JpegEncoder::new_with_quality() four times faster.
@HeroicKatora HeroicKatora added the next: blocked-msrv Issue blocked on minimum supported Rust version label Oct 5, 2020
@HeroicKatora HeroicKatora mentioned this pull request Feb 13, 2021
22 tasks
@HeroicKatora HeroicKatora changed the base branch from master to next March 10, 2021 20:39
@HeroicKatora HeroicKatora changed the base branch from next to master October 2, 2021 20:23
@HeroicKatora HeroicKatora merged commit f37f5fb into image-rs:master Oct 2, 2021
@HeroicKatora HeroicKatora deleted the const-build-huff branch October 2, 2021 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next: blocked-msrv Issue blocked on minimum supported Rust version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants