]> git.sesse.net Git - stockfish/commitdiff
Speedup moves root list sorting
authorMarco Costalba <mcostalba@gmail.com>
Mon, 27 Dec 2010 12:29:52 +0000 (13:29 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 27 Dec 2010 12:55:34 +0000 (13:55 +0100)
Instead of a default member by member copy use set_pv()
to copy the useful part of pv[] array and skip the remaining.

This greatly speeds up sorting of root move list !

No functional change.

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

index 7fa7c1bec53f37bf9e8bb2b92508ff2b0cedfd12..fdad3e51d50f9183c378f1aa1ded6205aa52d426 100644 (file)
@@ -113,7 +113,9 @@ namespace {
 
   struct RootMove {
 
-    RootMove() : nodes(0) { pv_score = non_pv_score = -VALUE_INFINITE; }
+    RootMove() : nodes(0) { pv_score = non_pv_score = -VALUE_INFINITE; move = pv[0] = MOVE_NONE; }
+    RootMove(const RootMove& rm) { *this = rm; }
+    RootMove& operator=(const RootMove& rm); // Skip costly full pv[] copy
 
     // RootMove::operator<() is the comparison function used when
     // sorting the moves. A move m1 is considered to be better
@@ -125,13 +127,19 @@ namespace {
     }
     void set_pv(const Move newPv[]);
 
-    Move move;
-    Value pv_score;
-    Value non_pv_score;
     int64_t nodes;
-    Move pv[PLY_MAX_PLUS_2];
+    Value pv_score, non_pv_score;
+    Move move, pv[PLY_MAX_PLUS_2];
   };
 
+  RootMove& RootMove::operator=(const RootMove& rm) {
+
+      pv_score = rm.pv_score; non_pv_score = rm.non_pv_score;
+      nodes = rm.nodes; move = rm.move;
+      set_pv(rm.pv);
+      return *this;
+  }
+
   void RootMove::set_pv(const Move newPv[]) {
 
     int i = -1;