From eb8b67e69aadb1d40263f8a14f11c5eaf7bc4249 Mon Sep 17 00:00:00 2001 From: Peter Bower <37089506+pbower@users.noreply.github.com> Date: Wed, 16 Sep 2026 21:19:22 +0100 Subject: [PATCH] Improve Matrix zero init --- Cargo.toml | 2 +- src/structs/matrix.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d53c786..e9873e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,7 @@ ahash = { version = "0.8.12", optional = true } hashbrown = { version = "0.15", optional = true } parking_lot = { version = "0.12", optional = true } regex = { version = "1.12.3", optional = true } -vec64 = { version = "0.5.1" } +vec64 = { version = "0.5.2" } log = { version = "0.4.29", optional = true } [dev-dependencies] diff --git a/src/structs/matrix.rs b/src/structs/matrix.rs index 9b3e023..0a7bc7a 100644 --- a/src/structs/matrix.rs +++ b/src/structs/matrix.rs @@ -120,8 +120,9 @@ impl Matrix { pub fn new(n_rows: usize, n_cols: usize, name: Option>) -> Self { let stride = aligned_stride(n_rows); let len = stride * n_cols; - let mut vec = Vec64::with_capacity(len); - vec.resize(len, 0.0); + // SAFETY: Zero bits are a valid `f64`, and the allocator's zeroed path hands + // back untouched zero pages + let vec = unsafe { Vec64::zeroed(len) }; let data = Arc::new(Buffer::from_vec64(vec)); Matrix { n_rows,