From 1395cc651809d1b86cd30681a68cb302f736d204 Mon Sep 17 00:00:00 2001 From: Luis Moreno Date: Fri, 5 Mar 2021 10:25:34 -0400 Subject: [PATCH] fix: Use usize time for usize::from_le_bytes buffer --- src/dataset/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dataset/mod.rs b/src/dataset/mod.rs index 31a12cf..17d3b72 100644 --- a/src/dataset/mod.rs +++ b/src/dataset/mod.rs @@ -82,8 +82,9 @@ pub(crate) fn deserialize_data( bytes: &[u8], ) -> Result<(Vec, Vec, usize, usize), io::Error> { // read the same file back into a Vec of bytes + const USIZE_SIZE: usize = std::mem::size_of::(); let (num_samples, num_features) = { - let mut buffer = [0u8; if cfg!(target_arch = "wasm32") { 4 } else { 8 }]; + let mut buffer = [0u8; USIZE_SIZE]; buffer.copy_from_slice(&bytes[0..8]); let num_features = usize::from_le_bytes(buffer); buffer.copy_from_slice(&bytes[8..16]);