mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-19 16:46:30 +08:00
Microptimize pawns info access
Avoid indirect calling of piece_of_color_and_type(c, PAWN) and its alias pawns(c) in the pawn evaluation loop, but use the pawns bitboards accessed only once before entering the loop. Also explicitly mark functions as static to better self-document. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -244,12 +244,13 @@ public:
|
||||
|
||||
// Information about pawns
|
||||
bool pawn_is_passed(Color c, Square s) const;
|
||||
bool pawn_is_isolated(Color c, Square s) const;
|
||||
bool pawn_is_doubled(Color c, Square s) const;
|
||||
static bool pawn_is_passed(Bitboard theirPawns, Color c, Square s);
|
||||
static bool pawn_is_isolated(Bitboard ourPawns, Square s);
|
||||
static bool pawn_is_doubled(Bitboard ourPawns, Color c, Square s);
|
||||
|
||||
// Open and half-open files
|
||||
bool file_is_open(File f) const;
|
||||
bool file_is_half_open(Color c, File f) const;
|
||||
static bool file_is_open(Bitboard pawns, File f);
|
||||
static bool file_is_half_open(Bitboard pawns, File f);
|
||||
|
||||
// Weak squares
|
||||
bool square_is_weak(Square s, Color c) const;
|
||||
@@ -591,20 +592,24 @@ inline bool Position::pawn_is_passed(Color c, Square s) const {
|
||||
return !(pawns(opposite_color(c)) & passed_pawn_mask(c, s));
|
||||
}
|
||||
|
||||
inline bool Position::pawn_is_isolated(Color c, Square s) const {
|
||||
return !(pawns(c) & neighboring_files_bb(s));
|
||||
inline bool Position::pawn_is_passed(Bitboard theirPawns, Color c, Square s) {
|
||||
return !(theirPawns & passed_pawn_mask(c, s));
|
||||
}
|
||||
|
||||
inline bool Position::pawn_is_doubled(Color c, Square s) const {
|
||||
return pawns(c) & squares_behind(c, s);
|
||||
inline bool Position::pawn_is_isolated(Bitboard ourPawns, Square s) {
|
||||
return !(ourPawns & neighboring_files_bb(s));
|
||||
}
|
||||
|
||||
inline bool Position::file_is_open(File f) const {
|
||||
return !(pawns() & file_bb(f));
|
||||
inline bool Position::pawn_is_doubled(Bitboard ourPawns, Color c, Square s) {
|
||||
return ourPawns & squares_behind(c, s);
|
||||
}
|
||||
|
||||
inline bool Position::file_is_half_open(Color c, File f) const {
|
||||
return !(pawns(c) & file_bb(f));
|
||||
inline bool Position::file_is_open(Bitboard pawns, File f) {
|
||||
return !(pawns & file_bb(f));
|
||||
}
|
||||
|
||||
inline bool Position::file_is_half_open(Bitboard pawns, File f) {
|
||||
return !(pawns & file_bb(f));
|
||||
}
|
||||
|
||||
inline bool Position::square_is_weak(Square s, Color c) const {
|
||||
|
||||
Reference in New Issue
Block a user