mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 18:17:02 +08:00
Use reference instead of pointer for pop_lsb() signature
This patch changes the pop_lsb() signature from Square pop_lsb(Bitboard*) to
Square pop_lsb(Bitboard&). This is more idomatic for C++ style signatures.
Passed a non-regression STC test:
LLR: 2.93 (-2.94,2.94) {-1.25,0.25}
Total: 21280 W: 1928 L: 1847 D: 17505
Ptnml(0-2): 71, 1427, 7558, 1518, 66
https://tests.stockfishchess.org/tests/view/6053a1e22433018de7a38e2f
We have verified that the generated binary is identical on gcc-10.
Closes https://github.com/official-stockfish/Stockfish/pull/3404
No functional change.
This commit is contained in:
committed by
Stéphane Nicolet
parent
ace9632c67
commit
ec42154ef2
@@ -102,13 +102,13 @@ namespace {
|
||||
|
||||
while (b1)
|
||||
{
|
||||
Square to = pop_lsb(&b1);
|
||||
Square to = pop_lsb(b1);
|
||||
*moveList++ = make_move(to - Up, to);
|
||||
}
|
||||
|
||||
while (b2)
|
||||
{
|
||||
Square to = pop_lsb(&b2);
|
||||
Square to = pop_lsb(b2);
|
||||
*moveList++ = make_move(to - Up - Up, to);
|
||||
}
|
||||
}
|
||||
@@ -127,13 +127,13 @@ namespace {
|
||||
Bitboard b3 = shift<Up >(pawnsOn7) & emptySquares;
|
||||
|
||||
while (b1)
|
||||
moveList = make_promotions<Type, UpRight>(moveList, pop_lsb(&b1), ksq);
|
||||
moveList = make_promotions<Type, UpRight>(moveList, pop_lsb(b1), ksq);
|
||||
|
||||
while (b2)
|
||||
moveList = make_promotions<Type, UpLeft >(moveList, pop_lsb(&b2), ksq);
|
||||
moveList = make_promotions<Type, UpLeft >(moveList, pop_lsb(b2), ksq);
|
||||
|
||||
while (b3)
|
||||
moveList = make_promotions<Type, Up >(moveList, pop_lsb(&b3), ksq);
|
||||
moveList = make_promotions<Type, Up >(moveList, pop_lsb(b3), ksq);
|
||||
}
|
||||
|
||||
// Standard and en passant captures
|
||||
@@ -144,13 +144,13 @@ namespace {
|
||||
|
||||
while (b1)
|
||||
{
|
||||
Square to = pop_lsb(&b1);
|
||||
Square to = pop_lsb(b1);
|
||||
*moveList++ = make_move(to - UpRight, to);
|
||||
}
|
||||
|
||||
while (b2)
|
||||
{
|
||||
Square to = pop_lsb(&b2);
|
||||
Square to = pop_lsb(b2);
|
||||
*moveList++ = make_move(to - UpLeft, to);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace {
|
||||
assert(b1);
|
||||
|
||||
while (b1)
|
||||
*moveList++ = make<EN_PASSANT>(pop_lsb(&b1), pos.ep_square());
|
||||
*moveList++ = make<EN_PASSANT>(pop_lsb(b1), pos.ep_square());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,14 +183,14 @@ namespace {
|
||||
Bitboard bb = piecesToMove & pos.pieces(Pt);
|
||||
|
||||
while (bb) {
|
||||
Square from = pop_lsb(&bb);
|
||||
Square from = pop_lsb(bb);
|
||||
|
||||
Bitboard b = attacks_bb<Pt>(from, pos.pieces()) & target;
|
||||
if constexpr (Checks)
|
||||
b &= pos.check_squares(Pt);
|
||||
|
||||
while (b)
|
||||
*moveList++ = make_move(from, pop_lsb(&b));
|
||||
*moveList++ = make_move(from, pop_lsb(b));
|
||||
}
|
||||
|
||||
return moveList;
|
||||
@@ -236,7 +236,7 @@ namespace {
|
||||
Square ksq = pos.square<KING>(Us);
|
||||
Bitboard b = attacks_bb<KING>(ksq) & target;
|
||||
while (b)
|
||||
*moveList++ = make_move(ksq, pop_lsb(&b));
|
||||
*moveList++ = make_move(ksq, pop_lsb(b));
|
||||
|
||||
if ((Type != CAPTURES) && pos.can_castle(Us & ANY_CASTLING))
|
||||
for (CastlingRights cr : { Us & KING_SIDE, Us & QUEEN_SIDE } )
|
||||
@@ -286,7 +286,7 @@ ExtMove* generate<QUIET_CHECKS>(const Position& pos, ExtMove* moveList) {
|
||||
|
||||
while (dc)
|
||||
{
|
||||
Square from = pop_lsb(&dc);
|
||||
Square from = pop_lsb(dc);
|
||||
PieceType pt = type_of(pos.piece_on(from));
|
||||
|
||||
Bitboard b = attacks_bb(pt, from, pos.pieces()) & ~pos.pieces();
|
||||
@@ -295,7 +295,7 @@ ExtMove* generate<QUIET_CHECKS>(const Position& pos, ExtMove* moveList) {
|
||||
b &= ~attacks_bb<QUEEN>(pos.square<KING>(~us));
|
||||
|
||||
while (b)
|
||||
*moveList++ = make_move(from, pop_lsb(&b));
|
||||
*moveList++ = make_move(from, pop_lsb(b));
|
||||
}
|
||||
|
||||
return us == WHITE ? generate_all<WHITE, QUIET_CHECKS>(pos, moveList)
|
||||
@@ -319,12 +319,12 @@ ExtMove* generate<EVASIONS>(const Position& pos, ExtMove* moveList) {
|
||||
// the king evasions in order to skip known illegal moves, which avoids any
|
||||
// useless legality checks later on.
|
||||
while (sliders)
|
||||
sliderAttacks |= line_bb(ksq, pop_lsb(&sliders)) & ~pos.checkers();
|
||||
sliderAttacks |= line_bb(ksq, pop_lsb(sliders)) & ~pos.checkers();
|
||||
|
||||
// Generate evasions for king, capture and non capture moves
|
||||
Bitboard b = attacks_bb<KING>(ksq) & ~pos.pieces(us) & ~sliderAttacks;
|
||||
while (b)
|
||||
*moveList++ = make_move(ksq, pop_lsb(&b));
|
||||
*moveList++ = make_move(ksq, pop_lsb(b));
|
||||
|
||||
if (more_than_one(pos.checkers()))
|
||||
return moveList; // Double check, only a king move can save the day
|
||||
|
||||
Reference in New Issue
Block a user