Skip to content
Snippets Groups Projects
Commit 3d96da9f authored by Pascal Engélibert's avatar Pascal Engélibert :bicyclist:
Browse files

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

parent b44d37db
No related branches found
No related tags found
1 merge request!4Edition cleanup
...@@ -123,17 +123,11 @@ impl FromBytes for GvaUtxoIdDbV1 { ...@@ -123,17 +123,11 @@ impl FromBytes for GvaUtxoIdDbV1 {
type Err = CorruptedBytes; type Err = CorruptedBytes;
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
if bytes.len() == 69 { Ok(Self(
// TODO uncomment when feature const_generics became stable ! bytes
/*let mut buffer = uninit_array![u8; 69]; .try_into()
buffer.as_out().copy_from_slice(bytes); .map_err(|_| CorruptedBytes("db corrupted".to_owned()))?,
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()))
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment