]> git.sesse.net Git - stockfish/commitdiff
Simplify a condition in gives_check()
authorMarco Costalba <mcostalba@gmail.com>
Sun, 1 Dec 2013 09:07:16 +0000 (10:07 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 1 Dec 2013 09:09:30 +0000 (10:09 +0100)
Now that aligned() is quite fast we can skip
some logic.

No functional change.

src/position.cpp

index d141b4881dc9a622b4218b79ef9c927cdb9628ae..2f3c62f552ac8fec90ef1e1bb3fa1d8f7600702e 100644 (file)
@@ -633,14 +633,11 @@ bool Position::gives_check(Move m, const CheckInfo& ci) const {
   if (ci.checkSq[pt] & to)
       return true;
 
-  // Discovery check ?
-  if (unlikely(ci.dcCandidates) && (ci.dcCandidates & from))
-  {
-      // For pawn and king moves we need to verify also direction
-      if (   (pt != PAWN && pt != KING)
-          || !aligned(from, to, king_square(~sideToMove)))
-          return true;
-  }
+  // Discovered check ?
+  if (   unlikely(ci.dcCandidates)
+      && (ci.dcCandidates & from)
+      && !aligned(from, to, king_square(~sideToMove)))
+      return true;
 
   // Can we skip the ugly special cases ?
   if (type_of(m) == NORMAL)