From f0e862616d4dec341a0ac31009253ed26a150538 Mon Sep 17 00:00:00 2001 From: Joshua Coles Date: Sat, 4 Mar 2023 13:02:46 +0000 Subject: [PATCH] Remove unneeded dim for VectorStorage --- src/clib.rs | 18 +----------------- src/system/model.rs | 2 +- src/system/storage.rs | 5 ++--- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/clib.rs b/src/clib.rs index 4f6f625..75e612c 100644 --- a/src/clib.rs +++ b/src/clib.rs @@ -13,7 +13,7 @@ pub struct CStorage(VectorStorage); #[no_mangle] pub extern "C" fn storage_new(grid_size: u32) -> &'static mut CStorage { - let mut pntr = Box::new(CStorage(VectorStorage::new(grid_size, 2))); + let mut pntr = Box::new(CStorage(VectorStorage::new(grid_size))); Box::leak(pntr) } @@ -30,22 +30,6 @@ pub extern "C" fn storage_deposit(storage: &mut CStorage, i: i32, j: i32, val: u #[no_mangle] pub extern "C" fn walk(d: u32, i: i32, j: i32) -> CPosition { return test::b(d, i, j); - - // match d { - // 0 => CPosition(i + 1, j), - // 1 => CPosition(i - 1, j), - // 2 => CPosition(i, j + 1), - // 3 => CPosition(i, j - 1), - // _ => panic!("Ahh"), - // } - - // let (dim, sign) = d.div_rem(&2); - // let sign = if sign == 0 { -1 } else { 1 }; - // // HACK: Our conventin and the MVA are different, since we are trying to strangle fig this, quick hack. - // let offset = Position::in_direction(1 - dim, sign * -1); - // let next = Position(i, j) + offset; - // - // CPosition(next.0, next.1) } mod test { diff --git a/src/system/model.rs b/src/system/model.rs index b3b4dd7..8041769 100644 --- a/src/system/model.rs +++ b/src/system/model.rs @@ -38,7 +38,7 @@ impl, W: Walker

> DLASystem { pub struct VectorStorage { backing: Vec, grid_size: u32, - dim: u32, } impl VectorStorage { - pub fn new(grid_size: u32, dim: u32) -> VectorStorage { - VectorStorage { grid_size, dim, backing: vec![false; grid_size.pow(dim) as usize] } + pub fn new(grid_size: u32) -> VectorStorage { + VectorStorage { grid_size, backing: vec![false; grid_size.pow(2) as usize] } } pub fn linear_index(&self, position: &Position) -> usize {