Skip to content

Commit

Permalink
use trivial copies for ByRole
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Dec 30, 2024
1 parent d384afc commit 720e623
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,7 @@ impl Board {

pub fn material_side(&self, color: Color) -> ByRole<u8> {
let side = self.by_color(color);
self.by_role
.as_ref()
.map(|pieces| (*pieces & side).count() as u8)
self.by_role.map(|pieces| (pieces & side).count() as u8)
}

pub fn material(&self) -> ByColor<ByRole<u8>> {
Expand Down
10 changes: 5 additions & 5 deletions src/zobrist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,9 +1329,9 @@ impl<P: Position> ZobristHash for P {
}

if let Some(pockets) = self.pockets() {
for (color, pocket) in pockets.as_ref().zip_color() {
for role in Role::ALL {
zobrist ^= V::zobrist_for_pocket(color, role, *pocket.get(role));
for (color, pocket) in pockets.zip_color() {
for (role, pieces) in pocket.zip_role() {
zobrist ^= V::zobrist_for_pocket(color, role, pieces);
}
}
}
Expand All @@ -1354,8 +1354,8 @@ impl<P: Position> ZobristHash for P {
}

if let Some(remaining_checks) = self.remaining_checks() {
for (color, remaining) in remaining_checks.as_ref().zip_color() {
zobrist ^= V::zobrist_for_remaining_checks(color, *remaining);
for (color, remaining) in remaining_checks.zip_color() {
zobrist ^= V::zobrist_for_remaining_checks(color, remaining);
}
}

Expand Down

0 comments on commit 720e623

Please sign in to comment.