Skip to content

Commit 22a8c4b

Browse files
BM123499Sopel97
authored andcommitted
Reduce amount of branching and work duplication in generate_moves.
1 parent ee3f7b6 commit 22a8c4b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/movegen.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,17 @@ namespace {
180180

181181
Bitboard bb = piecesToMove & pos.pieces(Pt);
182182

183+
if (!bb)
184+
return moveList;
185+
186+
[[maybe_unused]] const Bitboard checkSquares = pos.check_squares(Pt);
187+
183188
while (bb) {
184189
Square from = pop_lsb(&bb);
185190

186-
if (Checks && (Pt == BISHOP || Pt == ROOK || Pt == QUEEN)
187-
&& !(attacks_bb<Pt>(from) & target & pos.check_squares(Pt)))
188-
continue;
189-
190191
Bitboard b = attacks_bb<Pt>(from, pos.pieces()) & target;
191-
192-
if (Checks)
193-
b &= pos.check_squares(Pt);
192+
if constexpr (Checks)
193+
b &= checkSquares;
194194

195195
while (b)
196196
*moveList++ = make_move(from, pop_lsb(&b));

0 commit comments

Comments
 (0)