From 62eb3ec38cca04ac09156bb2693a9f8ca82b3da6 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 5 Mar 2026 14:58:16 -1245 Subject: make cached_mining_costs smaller to speed up the common path --- azalea/src/pathfinder/world.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/azalea/src/pathfinder/world.rs b/azalea/src/pathfinder/world.rs index 9e9cce83..98b22d70 100644 --- a/azalea/src/pathfinder/world.rs +++ b/azalea/src/pathfinder/world.rs @@ -352,7 +352,7 @@ impl CachedWorld { } // delay initialization so we don't have to create this if it's unused - // this uses about 48mb of memory. it *really* helps though. + // this uses about 2mb of memory. it *really* helps though. *cached_mining_costs = Some( vec![(RelBlockPos::new(i16::MAX, i32::MAX, i16::MAX), 0.); CACHED_MINING_COSTS_SIZE] .into(), @@ -568,13 +568,13 @@ impl CachedWorld { } } -const CACHED_MINING_COSTS_SIZE: usize = 2usize.pow(22); +const CACHED_MINING_COSTS_SIZE: usize = 2usize.pow(18); fn calculate_cached_mining_costs_index(pos: RelBlockPos) -> usize { - // create a 22-bit index by taking the bottom bits from each axis + // create an 18-bit index by taking the bottom bits from each axis - const X_BITS: usize = 8; + const X_BITS: usize = 6; const Y_BITS: usize = 6; - const Z_BITS: usize = 8; + const Z_BITS: usize = 6; const X_MASK: usize = (1 << X_BITS) - 1; const Y_MASK: usize = (1 << Y_BITS) - 1; -- cgit v1.2.3