]> git.sesse.net Git - stockfish/blobdiff - src/pawns.cpp
Micro-optimise dangerous condition
[stockfish] / src / pawns.cpp
index d2a53ef9679a1d69ee1655530b9af05cd39b382b..04ae01530e44c7611680fa0d2f05a16dd810221e 100644 (file)
@@ -188,7 +188,7 @@ namespace {
 
 namespace Pawns {
 
-/// init() initializes some tables by formula instead of hard-code their values
+/// init() initializes some tables by formula instead of hard-coding their values
 
 void init() {
 
@@ -252,14 +252,15 @@ Value Entry::shelter_storm(const Position& pos, Square ksq) {
 }
 
 
-/// Entry::update_safety() calculates and caches a bonus for king safety. It is
-/// called only when king square changes, about 20% of total king_safety() calls.
+/// Entry::update_safety() calculates and caches a bonus for king safety.
+/// It is called only when king square changes, which is about 20% of total
+/// king_safety() calls.
 
 template<Color Us>
 Score Entry::update_safety(const Position& pos, Square ksq) {
 
   kingSquares[Us] = ksq;
-  castleRights[Us] = pos.can_castle(Us);
+  castlingFlags[Us] = pos.can_castle(Us);
   minKPdistance[Us] = 0;
 
   Bitboard pawns = pos.pieces(Us, PAWN);
@@ -271,11 +272,11 @@ Score Entry::update_safety(const Position& pos, Square ksq) {
 
   Value bonus = shelter_storm<Us>(pos, ksq);
 
-  // If we can castle use the bonus after the castle if it is bigger
-  if (pos.can_castle(make_castle_right(Us, KING_SIDE)))
+  // If we can castle use the bonus after the castling if it is bigger
+  if (pos.can_castle(make_castling_flag(Us, KING_SIDE)))
       bonus = std::max(bonus, shelter_storm<Us>(pos, relative_square(Us, SQ_G1)));
 
-  if (pos.can_castle(make_castle_right(Us, QUEEN_SIDE)))
+  if (pos.can_castle(make_castling_flag(Us, QUEEN_SIDE)))
       bonus = std::max(bonus, shelter_storm<Us>(pos, relative_square(Us, SQ_C1)));
 
   return kingSafety[Us] = make_score(bonus, -16 * minKPdistance[Us]);