mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
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 <mcostalba@gmail.com>
This commit is contained in:
parent
aabd526f7c
commit
9144e48eb6
1 changed files with 4 additions and 6 deletions
|
@ -460,7 +460,9 @@ void Position::find_checkers() {
|
||||||
|
|
||||||
bool Position::pl_move_is_legal(Move m) const {
|
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 {
|
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(is_ok());
|
||||||
assert(move_is_ok(m));
|
assert(move_is_ok(m));
|
||||||
assert(pinned == pinned_pieces(side_to_move()));
|
assert(pinned == pinned_pieces(side_to_move()));
|
||||||
|
assert(!is_check());
|
||||||
// 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;
|
|
||||||
|
|
||||||
// Castling moves are checked for legality during move generation.
|
// Castling moves are checked for legality during move generation.
|
||||||
if (move_is_castle(m))
|
if (move_is_castle(m))
|
||||||
|
|
Loading…
Add table
Reference in a new issue