From: Marco Costalba Date: Thu, 18 Jun 2009 13:22:39 +0000 (+0200) Subject: Skip castle rights update when not needed X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=190f88e5324ffd048c5234e78b41748432dc7579 Skip castle rights update when not needed Micro optimization in do_move(), a quick check avoid us to update castle rights in almost 90% of cases. No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/position.cpp b/src/position.cpp index 3ae7f50d..c17c5c57 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -796,11 +796,14 @@ void Position::do_move(Move m, StateInfo& newSt, Bitboard dcCandidates) { pieceList[us][piece][index[from]] = to; index[to] = index[from]; - // Update castle rights - st->key ^= zobCastle[st->castleRights]; - st->castleRights &= castleRightsMask[from]; - st->castleRights &= castleRightsMask[to]; - st->key ^= zobCastle[st->castleRights]; + // Update castle rights, try to shortcut a common case + if ((castleRightsMask[from] & castleRightsMask[to]) != ALL_CASTLES) + { + st->key ^= zobCastle[st->castleRights]; + st->castleRights &= castleRightsMask[from]; + st->castleRights &= castleRightsMask[to]; + st->key ^= zobCastle[st->castleRights]; + } // Update checkers bitboard, piece must be already moved st->checkersBB = EmptyBoardBB;