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:
Marco Costalba
2009-09-23 21:45:32 +01:00
parent dcb323bf0d
commit 48b74142ef
3 changed files with 12 additions and 4 deletions

View File

@@ -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;