]> git.sesse.net Git - stockfish/commitdiff
Micro-optimze extension()
authorMarco Costalba <mcostalba@gmail.com>
Mon, 24 Aug 2009 16:41:24 +0000 (17:41 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 25 Aug 2009 14:11:05 +0000 (15:11 +0100)
Explicitly write the conditions for pawn to 7th
and passed pawn instead of wrapping in redundant
helpers.

Also retire the now unused move_is_pawn_push_to_7th()
and the never used move_was_passed_pawn_push() and
move_is_deep_pawn_push()

Function extension() is so time critical that this
simple patch speeds up the pgo compile of 0.5% and
it is also more clear what actually happens there.

No functional change.

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

index 0a1576d4308efafefe580bdc6ecbac4c687cec1a..d1d511d7a99501245b5633ba76febe65ac9f000c 100644 (file)
@@ -236,10 +236,7 @@ public:
   bool move_is_check(Move m) const;
   bool move_is_check(Move m, Bitboard dcCandidates) const;
   bool move_is_capture(Move m) const;
-  bool move_is_deep_pawn_push(Move m) const;
-  bool move_is_pawn_push_to_7th(Move m) const;
   bool move_is_passed_pawn_push(Move m) const;
-  bool move_was_passed_pawn_push(Move m) const;
   bool move_attacks_square(Move m, Square s) const;
 
   // Information about pawns
@@ -653,20 +650,6 @@ inline Phase Position::game_phase() const {
       return Phase(((npm - EndgameLimit) * 128) / (MidgameLimit - EndgameLimit));
 }
 
-inline bool Position::move_is_deep_pawn_push(Move m) const {
-
-  Color c = side_to_move();
-  return   piece_on(move_from(m)) == piece_of_color_and_type(c, PAWN)
-        && relative_rank(c, move_to(m)) > RANK_4;
-}
-
-inline bool Position::move_is_pawn_push_to_7th(Move m) const {
-
-  Color c = side_to_move();
-  return   piece_on(move_from(m)) == piece_of_color_and_type(c, PAWN)
-        && relative_rank(c, move_to(m)) == RANK_7;
-}
-
 inline bool Position::move_is_passed_pawn_push(Move m) const {
 
   Color c = side_to_move();
@@ -674,13 +657,6 @@ inline bool Position::move_is_passed_pawn_push(Move m) const {
         && pawn_is_passed(c, move_to(m));
 }
 
-inline bool Position::move_was_passed_pawn_push(Move m) const {
-
-  Color c = opposite_color(side_to_move());
-  return   piece_on(move_to(m)) == piece_of_color_and_type(c, PAWN)
-        && pawn_is_passed(c, move_to(m));
-}
-
 inline int Position::rule_50_counter() const {
 
   return st->rule50;
index e2fdc4be3b7c1040cea7dc9ece64c68ee942e255..23fe8ce7eb2f5f61cc0f0fbda48d2b695686f98c 100644 (file)
@@ -2267,12 +2267,13 @@ namespace {
 
     if (pos.type_of_piece_on(move_from(m)) == PAWN)
     {
-        if (pos.move_is_pawn_push_to_7th(m))
+        Color c = pos.side_to_move();
+        if (relative_rank(c, move_to(m)) == RANK_7)
         {
             result += PawnPushTo7thExtension[pvNode];
             *dangerous = true;
         }
-        if (pos.move_is_passed_pawn_push(m))
+        if (pos.pawn_is_passed(c, move_to(m)))
         {
             result += PassedPawnExtension[pvNode];
             *dangerous = true;