Avoid copy a Position to get a move's san notation

In move_to_san() we create by copy a new position just
to detect if move gives check. This could be very costly in
line_to_san() that calls move_to_san() for every move, so
create the position only once and pass a reference to move_to_san()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2010-01-25 16:22:50 +01:00
parent c5e71f5150
commit d844a75d2c
3 changed files with 8 additions and 7 deletions

View File

@@ -356,8 +356,9 @@ void Position::print(Move m) const {
std::cout << std::endl;
if (m != MOVE_NONE)
{
Position p(*this);
string col = (color_of_piece_on(move_from(m)) == BLACK ? ".." : "");
std::cout << "Move is: " << col << move_to_san(*this, m) << std::endl;
std::cout << "Move is: " << col << move_to_san(p, m) << std::endl;
}
for (Rank rank = RANK_8; rank >= RANK_1; rank--)
{