mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-17 23:56:23 +08:00
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 <mcostalba@gmail.com>
This commit is contained in:
@@ -796,11 +796,14 @@ void Position::do_move(Move m, StateInfo& newSt, Bitboard dcCandidates) {
|
|||||||
pieceList[us][piece][index[from]] = to;
|
pieceList[us][piece][index[from]] = to;
|
||||||
index[to] = index[from];
|
index[to] = index[from];
|
||||||
|
|
||||||
// Update castle rights
|
// Update castle rights, try to shortcut a common case
|
||||||
|
if ((castleRightsMask[from] & castleRightsMask[to]) != ALL_CASTLES)
|
||||||
|
{
|
||||||
st->key ^= zobCastle[st->castleRights];
|
st->key ^= zobCastle[st->castleRights];
|
||||||
st->castleRights &= castleRightsMask[from];
|
st->castleRights &= castleRightsMask[from];
|
||||||
st->castleRights &= castleRightsMask[to];
|
st->castleRights &= castleRightsMask[to];
|
||||||
st->key ^= zobCastle[st->castleRights];
|
st->key ^= zobCastle[st->castleRights];
|
||||||
|
}
|
||||||
|
|
||||||
// Update checkers bitboard, piece must be already moved
|
// Update checkers bitboard, piece must be already moved
|
||||||
st->checkersBB = EmptyBoardBB;
|
st->checkersBB = EmptyBoardBB;
|
||||||
|
|||||||
Reference in New Issue
Block a user