mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-18 08:07:08 +08:00
Micro optimization of generate_piece_moves()
This patch make the piece list always terminated by SQ_NONE, so that we can use a simpler and faster loop in move generation. Speedup is about 0.6%. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -476,10 +476,10 @@ namespace {
|
||||
|
||||
Square from;
|
||||
Bitboard b;
|
||||
const Square* ptr = pos.piece_list_begin(us, Piece);
|
||||
|
||||
for (int i = 0, e = pos.piece_count(us, Piece); i < e; i++)
|
||||
while ((from = *ptr++) != SQ_NONE)
|
||||
{
|
||||
from = pos.piece_list(us, Piece, i);
|
||||
b = pos.attacks_from<Piece>(from) & target;
|
||||
SERIALIZE_MOVES(b);
|
||||
}
|
||||
@@ -502,10 +502,10 @@ namespace {
|
||||
Color us, Bitboard target, Bitboard pinned) {
|
||||
Square from;
|
||||
Bitboard b;
|
||||
const Square* ptr = pos.piece_list_begin(us, Piece);
|
||||
|
||||
for (int i = 0, e = pos.piece_count(us, Piece); i < e; i++)
|
||||
while ((from = *ptr++) != SQ_NONE)
|
||||
{
|
||||
from = pos.piece_list(us, Piece, i);
|
||||
if (pinned && bit_is_set(pinned, from))
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user