From 9c4161f6885e312a06282750bec294283b26b857 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 6 Aug 2023 12:32:14 +0200 Subject: [PATCH] util: turn range check into debug_assert!() More performance optimization. --- src/util.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/util.rs b/src/util.rs index 436c070..43245ca 100644 --- a/src/util.rs +++ b/src/util.rs @@ -40,13 +40,8 @@ pub fn coord_offset( let coord = ((chunk.0 as i32) << BLOCK_BITS | block.0 as i32) + offset; let (region_chunk, block) = coord.shift_mask(BLOCK_BITS); let (region, chunk) = region_chunk.shift_mask(CHUNK_BITS); - ( - region - .try_into() - .expect("the region coordinate should be in the valid range"), - ChunkCoord::new(chunk), - BlockCoord::new(block), - ) + debug_assert!(i8::try_from(region).is_ok()); + (region as i8, ChunkCoord::new(chunk), BlockCoord::new(block)) } #[cfg(test)]