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

Remove ArrayEncoding usage from Digest and delete ArrayEncoding. #1731

Merged
merged 2 commits into from
Nov 22, 2023

Commits on Nov 22, 2023

  1. Configuration menu
    Copy the full SHA
    2e661e4 View commit details
    Browse the repository at this point in the history
  2. Remove ArrayEncoding usage from Digest and delete ArrayEncoding.

    Note: I originally tried an alternative implementation using `flat_map` that
    ended up being materially slower. To fix that performance regression I had to
    make the following change:
    
    ```
         let mut output = Output([0; MAX_OUTPUT_LEN]);
         output
             .0
    -        .iter_mut()
    -        .zip(input.iter().copied().flat_map(|Wrapping(w)| f(w)))
    +        .chunks_mut(N)
    +        .zip(input.iter().copied().map(|Wrapping(w)| f(w)))
             .for_each(|(o, i)| {
    -            *o = i;
    +            o.copy_from_slice(&i);
             });
         output
     }
    ```
    
    I verified that this generates the same assembly code as the original code
    on x86-64 using Rust 1.74.0, except that there are two additional 128-bit
    moves in `sha256_formta_output` to zero out the latter half of `Output`,
    which was intended.
    briansmith committed Nov 22, 2023
    Configuration menu
    Copy the full SHA
    149904c View commit details
    Browse the repository at this point in the history