From e68dd99fba0ffc902b45de42870a41fc60111927 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 24 Jan 2024 20:49:45 +0100 Subject: [PATCH] Avoid unnecessary error handling in from_wasm_bytes --- packages/vm/src/memory.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/vm/src/memory.rs b/packages/vm/src/memory.rs index e8e2a45b23..5870b23711 100644 --- a/packages/vm/src/memory.rs +++ b/packages/vm/src/memory.rs @@ -31,9 +31,9 @@ type RegionBytes = [u8; size_of::()]; impl Region { fn from_wasm_bytes(bytes: RegionBytes) -> Self { - let offset = u32::from_le_bytes(bytes[0..4].try_into().unwrap()); - let capacity = u32::from_le_bytes(bytes[4..8].try_into().unwrap()); - let length = u32::from_le_bytes(bytes[8..12].try_into().unwrap()); + let offset = u32::from_le_bytes([bytes[0], bytes[1], bytes[2], bytes[3]]); + let capacity = u32::from_le_bytes([bytes[4], bytes[5], bytes[6], bytes[7]]); + let length = u32::from_le_bytes([bytes[8], bytes[9], bytes[10], bytes[11]]); Region { offset, capacity,