Bitboard bb = piecesToMove & pos.pieces(Pt);
+ if (!bb)
+ return moveList;
+
+ [[maybe_unused]] const Bitboard checkSquares = pos.check_squares(Pt);
+
while (bb) {
Square from = pop_lsb(&bb);
- if (Checks && (Pt == BISHOP || Pt == ROOK || Pt == QUEEN)
- && !(attacks_bb<Pt>(from) & target & pos.check_squares(Pt)))
- continue;
-
Bitboard b = attacks_bb<Pt>(from, pos.pieces()) & target;
-
- if (Checks)
- b &= pos.check_squares(Pt);
+ if constexpr (Checks)
+ b &= checkSquares;
while (b)
*moveList++ = make_move(from, pop_lsb(&b));