]> git.sesse.net Git - stockfish/commitdiff
MovePicker: simplify move swapping
authorMarco Costalba <mcostalba@gmail.com>
Thu, 18 Sep 2008 08:51:24 +0000 (09:51 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 18 Sep 2008 10:26:10 +0000 (12:26 +0200)
We don't need a full swap here because once found
and returned the best move will not be used again.

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

index 6df070bbdf167b8e835a1970eb5099f846dbcfd7..235191af96bdad297144123f662dd1f503aba2f5 100644 (file)
@@ -335,10 +335,8 @@ Move MovePicker::pick_move_from_list() {
         }
       }
       if(bestIndex != -1) { // Found a good capture
-        MoveStack tmp = moves[movesPicked];
-        moves[movesPicked] = moves[bestIndex];
-        moves[bestIndex] = tmp;
-        move = moves[movesPicked++].move;
+        move = moves[bestIndex].move;\r
+        moves[bestIndex] = moves[movesPicked++];
         if(move != ttMove && move != mateKiller &&
            pos->move_is_legal(move, pinned))
           return move;
@@ -368,10 +366,8 @@ Move MovePicker::pick_move_from_list() {
         bestIndex = movesPicked;
 
       if(bestIndex != -1) {
-        MoveStack tmp = moves[movesPicked];
-        moves[movesPicked] = moves[bestIndex];
-        moves[bestIndex] = tmp;
-        move = moves[movesPicked++].move;
+        move = moves[bestIndex].move;\r
+        moves[bestIndex] = moves[movesPicked++];
         if(move != ttMove && move != mateKiller &&
            pos->move_is_legal(move, pinned))
           return move;
@@ -392,10 +388,8 @@ Move MovePicker::pick_move_from_list() {
         }
 
       if(bestIndex != -1) {
-        MoveStack tmp = moves[movesPicked];
-        moves[movesPicked] = moves[bestIndex];
-        moves[bestIndex] = tmp;
-        move = moves[movesPicked++].move;
+        move = moves[bestIndex].move;\r
+        moves[bestIndex] = moves[movesPicked++];
         return move;
       }
     }
@@ -431,11 +425,8 @@ Move MovePicker::pick_move_from_list() {
         bestIndex = movesPicked;
 
       if(bestIndex != -1) {
-        MoveStack tmp = moves[movesPicked];
-        moves[movesPicked] = moves[bestIndex];
-        moves[bestIndex] = tmp;
-
-        move = moves[movesPicked++].move;
+        move = moves[bestIndex].move;\r
+        moves[bestIndex] = moves[movesPicked++];
         // Remember to change the line below if we decide to hash the qsearch!
         // Maybe also postpone the legality check until after futility pruning?
         if(/* move != ttMove && */ pos->move_is_legal(move, pinned))