Skip to content

Commit fc23e44

Browse files
authored
Faster is_noisy (#1069)
is_noisy_main: movzx eax, di shr eax, 12 mov ecx, 63536 bt ecx, eax setb al ret is_noisy_patch: and edi, 28672 cmp edi, 8193 setae al ret No functional change. Bench: 3634130
1 parent fec9098 commit fc23e44

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

src/types/moves.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,10 @@ impl Move {
6565
self.is_present() && !self.is_noisy()
6666
}
6767

68+
// Sneaky bit-twidling. If we just look at the last 3 bits (& 7), anything
69+
// greater than Castling is a queen push promotion or a capture.
6870
pub const fn is_noisy(self) -> bool {
69-
matches!(
70-
self.kind(),
71-
MoveKind::Capture
72-
| MoveKind::EnPassant
73-
| MoveKind::PromotionQ
74-
| MoveKind::PromotionCaptureN
75-
| MoveKind::PromotionCaptureB
76-
| MoveKind::PromotionCaptureR
77-
| MoveKind::PromotionCaptureQ
78-
)
71+
(self.kind() as u8 & 7) > MoveKind::Castling as u8
7972
}
8073

8174
pub const fn is_special(self) -> bool {

0 commit comments

Comments
 (0)