improve benchmarks and marginal perf improvements

This commit is contained in:
2025-02-18 16:27:04 -05:00
parent 1972707f88
commit 0fea3da31c
3 changed files with 32 additions and 24 deletions

View File

@@ -166,7 +166,7 @@ impl Board {
}
/// Get a reference to a backing [`BitBoard`]
pub fn board(&self, color: Piece) -> &BitBoard {
pub const fn board(&self, color: Piece) -> &BitBoard {
match color {
Piece::Black => &self.black_board,
Piece::White => &self.white_board,
@@ -174,7 +174,7 @@ impl Board {
}
/// Get a mutable reference to a backing [`BitBoard`]
pub fn board_mut(&mut self, color: Piece) -> &mut BitBoard {
pub const fn board_mut(&mut self, color: Piece) -> &mut BitBoard {
match color {
Piece::Black => &mut self.black_board,
Piece::White => &mut self.white_board,
@@ -225,11 +225,12 @@ impl Board {
}
pub fn place(&mut self, i: usize, j: usize, piece: Piece) -> Result<(), &'static str> {
if let Some(what_if_result) = self.what_if(i, j, piece) {
*self = what_if_result;
return Ok(());
}
Err("move would not propegate")
let what_if_result = self
.what_if(i, j, piece)
.ok_or("move would not propegate")?;
*self = what_if_result;
return Ok(());
}
/// Propegate the board and captures starting from a specific position