From 791ba3906d0ec41f328c20a9a1be8eabb12a84c6 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 24 Aug 2023 02:36:14 +0300 Subject: perf: use iterator in bitboard serialization --- src/grossmeister/evaluation.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/grossmeister') diff --git a/src/grossmeister/evaluation.rs b/src/grossmeister/evaluation.rs index 6669545..b78c49a 100644 --- a/src/grossmeister/evaluation.rs +++ b/src/grossmeister/evaluation.rs @@ -190,7 +190,7 @@ impl Grossmeister { } _ => panic!("Unreachable") }; - total + bitboard.serialize().iter().fold(0., |acc, &square| { + total + bitboard.serialize().fold(0., |acc, square| { let pst_index = match color { Color::White => square.mirror(), Color::Black => square, @@ -280,8 +280,8 @@ impl Grossmeister { Color::White => self.board.piece_sets[Piece::PawnBlack as usize], }; - let pawn_attacked_squares = opponent_pawns.serialize().iter().fold(0u64, |acc, square| { - acc | self.board.attacks.pawn[color.flip() as usize][*square as usize] + let pawn_attacked_squares = opponent_pawns.serialize().fold(0u64, |acc, square| { + acc | self.board.attacks.pawn[color.flip() as usize][square as usize] }); // Exclude squares controlled by enemy pawns from mobility @@ -325,7 +325,6 @@ impl Grossmeister { if *piece == king_home_position.to_bitboard() { for rook_square in player_pieces[Piece::Rook as usize] .serialize() - .iter() .filter(|rook_square| rook_square.rank() == king_home_position.rank()) { match rook_square.file() { -- cgit v1.2.3