Commit 3d96da9f authored by Pascal Engélibert's avatar Pascal Engélibert 🚴
Browse files

perf(db): GvaUtxoIdDbV1::from_bytes avoid zeroed init

parent b44d37db
Pipeline #14238 failed with stages
in 6 minutes and 20 seconds
......@@ -123,17 +123,11 @@ impl FromBytes for GvaUtxoIdDbV1 {
type Err = CorruptedBytes;
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
if bytes.len() == 69 {
// TODO uncomment when feature const_generics became stable !
/*let mut buffer = uninit_array![u8; 69];
buffer.as_out().copy_from_slice(bytes);
Ok(Self(unsafe { std::mem::transmute(buffer) }))*/
let mut buffer = [0u8; 69];
buffer.copy_from_slice(bytes);
Ok(Self(buffer))
} else {
Err(CorruptedBytes("db corrupted".to_owned()))
}
Ok(Self(
bytes
.try_into()
.map_err(|_| CorruptedBytes("db corrupted".to_owned()))?,
))
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment