Skip to content

Commit

Permalink
updated minimum rust to 1.64 to support stabilized NonZeroU32::unsign…
Browse files Browse the repository at this point in the history
…ed_abs. This has a significant speed impact on leading zero calc on x86
  • Loading branch information
mcroomp committed Apr 20, 2023
1 parent 0613c49 commit 34e1e63
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: ["1.61.0", stable, beta, nightly]
rust: ["1.64.0", stable, beta, nightly]
features: [gif, jpeg, png, tiff, ico, pnm, tga, webp, bmp, hdr, dxt, dds, farbfeld, openexr, jpeg_rayon, webp-encoder, '']
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2018"
resolver = "2"

# note: when changed, also update test runner in `.github/workflows/rust.yml`
rust-version = "1.61.0"
rust-version = "1.64.0"

license = "MIT"
description = "Imaging library written in Rust. Provides basic filters and decoders for the most common image formats."
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/jpeg/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ fn build_quantization_segment(m: &mut Vec<u8>, precision: u8, identifier: u8, qt
fn encode_coefficient(coefficient: i32) -> (u8, u16) {
// since this is inlined, in the main AC case the compiler figures out that coefficient cannot be zero, so BSR on x86 doesn't need a branch
if let Some(nz) = NonZeroI32::new(coefficient) {
let leading_zeros = nz.abs().leading_zeros() as u8;
let leading_zeros = nz.unsigned_abs().leading_zeros() as u8;

// first shift right signed by 31 to make everything 1 if negative,
// then shift right unsigned to make the leading bits 0
Expand Down

0 comments on commit 34e1e63

Please sign in to comment.