improve benchmarks and marginal perf improvements
This commit is contained in:
15
src/board.rs
15
src/board.rs
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user