mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-17 15:46:24 +08:00
Micro optimize pretty_pv
Creating an History object requires clearing the History tables, although fast is an useless job in san.cpp where History is used just as a dummy argument for MovePicker c'tor. So use a file scoped constant instead of creating a new History() object each time MovePicker c'tor is called as in move_ambiguity() This optimizes pretty_pv() through the following calling chain: pretty_pv() -> line_to_san() -> move_to_san() -> move_ambiguity() No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -40,8 +40,6 @@ using std::string;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/// Types
|
|
||||||
|
|
||||||
enum Ambiguity {
|
enum Ambiguity {
|
||||||
AMBIGUITY_NONE,
|
AMBIGUITY_NONE,
|
||||||
AMBIGUITY_FILE,
|
AMBIGUITY_FILE,
|
||||||
@@ -49,8 +47,7 @@ namespace {
|
|||||||
AMBIGUITY_BOTH
|
AMBIGUITY_BOTH
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const History H; // used as dummy argument for MovePicker c'tor
|
||||||
/// Functions
|
|
||||||
|
|
||||||
Ambiguity move_ambiguity(const Position& pos, Move m);
|
Ambiguity move_ambiguity(const Position& pos, Move m);
|
||||||
const string time_string(int milliseconds);
|
const string time_string(int milliseconds);
|
||||||
@@ -144,7 +141,7 @@ Move move_from_san(const Position& pos, const string& movestr) {
|
|||||||
|
|
||||||
assert(pos.is_ok());
|
assert(pos.is_ok());
|
||||||
|
|
||||||
MovePicker mp = MovePicker(pos, false, MOVE_NONE, OnePly, History());
|
MovePicker mp = MovePicker(pos, false, MOVE_NONE, OnePly, H);
|
||||||
|
|
||||||
// Castling moves
|
// Castling moves
|
||||||
if (movestr == "O-O-O" || movestr == "O-O-O+")
|
if (movestr == "O-O-O" || movestr == "O-O-O+")
|
||||||
@@ -368,7 +365,7 @@ namespace {
|
|||||||
if (type_of_piece(pc) == KING)
|
if (type_of_piece(pc) == KING)
|
||||||
return AMBIGUITY_NONE;
|
return AMBIGUITY_NONE;
|
||||||
|
|
||||||
MovePicker mp = MovePicker(pos, false, MOVE_NONE, OnePly, History());
|
MovePicker mp = MovePicker(pos, false, MOVE_NONE, OnePly, H);
|
||||||
Move mv, moveList[8];
|
Move mv, moveList[8];
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user