From 9144e48eb63587bde7379c16ddb3defea4b0e409 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sat, 2 May 2009 16:47:06 +0100 Subject: [PATCH] Avoid an usless check in pl_move_is_legal Although very cheap this is a very hot path, so avoid it. No functional change. Signed-off-by: Marco Costalba --- src/position.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 5f194030..4184e494 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -460,7 +460,9 @@ void Position::find_checkers() { bool Position::pl_move_is_legal(Move m) const { - return pl_move_is_legal(m, pinned_pieces(side_to_move())); + // If we're in check, all pseudo-legal moves are legal, because our + // check evasion generator only generates true legal moves. + return is_check() || pl_move_is_legal(m, pinned_pieces(side_to_move())); } bool Position::pl_move_is_legal(Move m, Bitboard pinned) const { @@ -468,11 +470,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const { assert(is_ok()); assert(move_is_ok(m)); assert(pinned == pinned_pieces(side_to_move())); - - // If we're in check, all pseudo-legal moves are legal, because our - // check evasion generator only generates true legal moves. - if (is_check()) - return true; + assert(!is_check()); // Castling moves are checked for legality during move generation. if (move_is_castle(m)) -- 2.39.2