From e09a0f3345f5d6ba929b818393026c989b4354c3 Mon Sep 17 00:00:00 2001 From: Morten Lohne Date: Sun, 21 Jan 2024 22:57:59 +0100 Subject: [PATCH] Micro-optimizations --- src/evaluation/policy_eval.rs | 4 ++-- src/position/mod.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/evaluation/policy_eval.rs b/src/evaluation/policy_eval.rs index 4f6144cb..b8939e0c 100644 --- a/src/evaluation/policy_eval.rs +++ b/src/evaluation/policy_eval.rs @@ -192,8 +192,8 @@ fn has_immediate_win(policy_features: &PolicyFeatures) -> bool { policy_features.move_onto_critical_square[1], policy_features.spread_that_connects_groups_to_win[0], ] - .iter() - .any(|p| *p != 0.0) + .into_iter() + .any(|p| p != 0.0) } struct MovementSynopsis { diff --git a/src/position/mod.rs b/src/position/mod.rs index ca725064..fd865b7b 100644 --- a/src/position/mod.rs +++ b/src/position/mod.rs @@ -763,7 +763,7 @@ impl Position { for square in square::squares_iterator::() { group_data.amount_in_group[group_data.groups[square] as usize].0 += 1; - if self[square].top_stone().map(Piece::is_road_piece) == Some(true) { + if self[square].top_stone().is_some_and(Piece::is_road_piece) { group_data.amount_in_group[group_data.groups[square] as usize].1 = group_data.amount_in_group[group_data.groups[square] as usize].1 | square.group_edge_connection();