From 30c14fdc9532fc94217eba708653a188a9b24504 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Mon, 27 Dec 2010 13:29:52 +0100 Subject: [PATCH] Speedup moves root list sorting 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 --- src/search.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 7fa7c1be..fdad3e51 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -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;