bitboard: use explicit bit representation
This commit is contained in:
parent
76516a36dd
commit
8c5fea8359
@ -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)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user