]> git.sesse.net Git - stockfish/commitdiff
Simplify generate_castling (#1885)
authorprotonspring <mike@whiteley.org>
Sun, 23 Dec 2018 15:05:24 +0000 (08:05 -0700)
committerMarco Costalba <mcostalba@users.noreply.github.com>
Sun, 23 Dec 2018 15:05:24 +0000 (16:05 +0100)
Although this is a compile-time constant, we stick the castlingSide into a CastlingRight, then pull it out again. This seems unecessarily complex.

No functional change.

src/movegen.cpp

index b4a9d27ba1d7459fcc959ba30fc4fe88a84a6a1b..76a27d9f4936320165c0378f2b59225038b0abbe 100644 (file)
@@ -29,7 +29,7 @@ namespace {
   ExtMove* generate_castling(const Position& pos, ExtMove* moveList) {
 
     constexpr CastlingRight Cr = Us | Cs;
   ExtMove* generate_castling(const Position& pos, ExtMove* moveList) {
 
     constexpr CastlingRight Cr = Us | Cs;
-    constexpr bool KingSide = (Cr == WHITE_OO || Cr == BLACK_OO);
+    constexpr bool KingSide = (Cs == KING_SIDE);
 
     if (pos.castling_impeded(Cr) || !pos.can_castle(Cr))
         return moveList;
 
     if (pos.castling_impeded(Cr) || !pos.can_castle(Cr))
         return moveList;