removed unneeded extra alloc
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user