]> git.sesse.net Git - stockfish/commitdiff
Fix a performance bug in generate_move_if_legal
authorMarco Costalba <mcostalba@gmail.com>
Thu, 23 Oct 2008 20:02:10 +0000 (21:02 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 24 Oct 2008 19:10:05 +0000 (21:10 +0200)
Use the pinned argument in pos.move_is_legal()

No functional change, simply use pos.move_is_legal() as
was meant to be.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/movegen.cpp

index ecda2c2d4640cd10b620ec5f85230850d089b6ac..caec09aa4f4b31b6121e15bbfe7691a98fe1a23c 100644 (file)
@@ -429,7 +429,7 @@ Move generate_move_if_legal(const Position& pos, Move m, Bitboard pinned) {
       assert(pos.piece_on(to - pawn_push(us)) == pawn_of_color(them));
 
       // The move is pseudo-legal.  If it is legal, return it.
       assert(pos.piece_on(to - pawn_push(us)) == pawn_of_color(them));
 
       // The move is pseudo-legal.  If it is legal, return it.
-      return (pos.move_is_legal(m) ? m : MOVE_NONE);
+      return (pos.move_is_legal(m, pinned) ? m : MOVE_NONE);
   }
 
   // Castling moves
   }
 
   // Castling moves
@@ -561,12 +561,12 @@ Move generate_move_if_legal(const Position& pos, Move m, Bitboard pinned) {
           return MOVE_NONE;
       }
       // The move is pseudo-legal.  Return it if it is legal.
           return MOVE_NONE;
       }
       // The move is pseudo-legal.  Return it if it is legal.
-      return (pos.move_is_legal(m) ? m : MOVE_NONE);
+      return (pos.move_is_legal(m, pinned) ? m : MOVE_NONE);
   }
 
   // Luckly we can handle all the other pieces in one go
   return (   pos.piece_attacks_square(from, to)
   }
 
   // Luckly we can handle all the other pieces in one go
   return (   pos.piece_attacks_square(from, to)
-          && pos.move_is_legal(m)
+          && pos.move_is_legal(m, pinned)
           && !move_promotion(m) ? m : MOVE_NONE);
 }
 
           && !move_promotion(m) ? m : MOVE_NONE);
 }