util: turn range check into debug_assert!()

More performance optimization.
This commit is contained in:
Matthias Schiffer 2023-08-06 12:32:14 +02:00
parent 21035a1f7f
commit 9c4161f688
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C

View file

@ -40,13 +40,8 @@ pub fn coord_offset<const AXIS: u8>(
let coord = ((chunk.0 as i32) << BLOCK_BITS | block.0 as i32) + 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, block) = coord.shift_mask(BLOCK_BITS);
let (region, chunk) = region_chunk.shift_mask(CHUNK_BITS); let (region, chunk) = region_chunk.shift_mask(CHUNK_BITS);
( debug_assert!(i8::try_from(region).is_ok());
region (region as i8, ChunkCoord::new(chunk), BlockCoord::new(block))
.try_into()
.expect("the region coordinate should be in the valid range"),
ChunkCoord::new(chunk),
BlockCoord::new(block),
)
} }
#[cfg(test)] #[cfg(test)]