bitboard: use explicit bit representation

This commit is contained in:
Simon Gardling 2025-02-19 20:18:38 -05:00
parent 76516a36dd
commit 8c5fea8359
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -45,14 +45,14 @@ impl BitBoard {
#[cfg(not(feature = "bitvec"))]
pub const fn get(&self, row: usize, col: usize) -> bool {
((self.0 >> Self::get_index(row, col)) & 1) != 0
((self.0 >> Self::get_index(row, col)) & 0b1) != 0b0
}
#[cfg(not(feature = "bitvec"))]
pub const fn set(&mut self, row: usize, col: usize, value: bool) {
let index = Self::get_index(row, col);
// PERF! branchless setting of bit (~+3% perf bump)
self.0 &= !(1 << index); // clear bit
self.0 &= !(0b1 << index); // clear bit
self.0 |= (value as BitBoardInner) << index; // set bit (if needed)
}