removed unneeded extra alloc

This commit is contained in:
2025-08-17 13:24:44 -04:00
parent 41841cdcd6
commit 5a6311f20f
4 changed files with 12 additions and 16 deletions

View File

@@ -20,11 +20,10 @@ impl Hasher for BLAKE256 {
self.hasher.update(bytes.as_ref())
}
fn complete(self) -> HashReturn {
fn complete(mut self) -> HashReturn {
let res = self.hasher.finalize_boxed();
let mut ret = BITS256::default();
ret.copy_from_slice(&res);
HashReturn::BLAKE256(ret)
self.hash.copy_from_slice(&res);
HashReturn::BLAKE256(self.hash)
}
}

View File

@@ -17,11 +17,10 @@ impl Hasher for BLAKE3 {
self.hasher.update(bytes.as_ref());
}
fn complete(self) -> HashReturn {
fn complete(mut self) -> HashReturn {
let res = self.hasher.finalize();
let mut ret = BITS256::default();
ret.copy_from_slice(res.as_bytes());
HashReturn::BLAKE3(ret)
self.hash.copy_from_slice(res.as_bytes());
HashReturn::BLAKE3(self.hash)
}
}

View File

@@ -22,11 +22,10 @@ impl Hasher for BLAKE512 {
self.hasher.update(bytes.as_ref())
}
fn complete(self) -> HashReturn {
fn complete(mut self) -> HashReturn {
let res = self.hasher.finalize_boxed();
let mut ret = bits512_default();
ret.copy_from_slice(&res);
HashReturn::BLAKE512(ret)
self.hash.copy_from_slice(&res);
HashReturn::BLAKE512(self.hash)
}
}

View File

@@ -19,11 +19,10 @@ impl Hasher for MD5 {
self.hasher.update(bytes.as_ref())
}
fn complete(self) -> HashReturn {
fn complete(mut self) -> HashReturn {
let res = self.hasher.finalize();
let mut ret = BITS128::default();
ret.copy_from_slice(&res);
HashReturn::MD5(ret)
self.hash.copy_from_slice(&res);
HashReturn::MD5(self.hash)
}
}