Skip to content

Commit

Permalink
Remove more code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanUkhov committed Apr 28, 2024
1 parent ca523c7 commit 6658769
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,12 @@ impl core::io::Write for Context {
/// Compute the digest of data.
#[allow(clippy::needless_range_loop)]
pub fn compute<T: AsRef<[u8]>>(data: T) -> Digest {
let mut state = STATE;
let mut buffer: [u8; 64] = [0; 64];
let mut cursor = 0;
let mut length = 0;
let Context {
mut state,
mut buffer,
mut cursor,
mut length,
} = Context::new();
let data = data.as_ref();
consume(&mut state, &mut buffer, &mut cursor, &mut length, data);
Digest(finalize(&mut state, &mut buffer, cursor, data.len() as u64))
Expand Down

0 comments on commit 6658769

Please sign in to comment.