From 1a8f63a8963fa9c3afd043f4c611df8a5afcf038 Mon Sep 17 00:00:00 2001 From: Reuven Peleg Date: Fri, 19 Jul 2013 17:01:07 +0200 Subject: [PATCH] Microptimize gives_check() for castling case Without patch we have 333198 nps, with patch 334249. A very small +0.3%, not a lot manily becuase this is a side path that is taken very few times. Anyhow idea is correct becuase first 'quick' condition has an hit rate of about 95%. No functional change. --- src/position.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 1273a62f..ad7ed3d9 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -690,9 +690,9 @@ bool Position::move_gives_check(Move m, const CheckInfo& ci) const { Square rfrom = to; // 'King captures the rook' notation Square kto = relative_square(us, rfrom > kfrom ? SQ_G1 : SQ_C1); Square rto = relative_square(us, rfrom > kfrom ? SQ_F1 : SQ_D1); - Bitboard b = (pieces() ^ kfrom ^ rfrom) | rto | kto; - return attacks_bb(rto, b) & ksq; + return (PseudoAttacks[ROOK][rto] & ksq) + && (attacks_bb(rto, (pieces() ^ kfrom ^ rfrom) | rto | kto) & ksq); } default: assert(false); -- 2.39.2