Delay sorting of negative scored non-captures

We can do this only when needed, if we get a cut-off
before we skip sorting entirely. This reduces sorting
time of about 20%.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2010-02-05 18:17:52 +01:00
parent 69644d3f73
commit c7866a4215
3 changed files with 10 additions and 5 deletions

View File

@@ -89,7 +89,7 @@ inline void insertion_sort(T* firstMove, T* lastMove)
// Our dedicated sort in range [firstMove, lastMove), first splits
// positive scores from ramining then order seaprately the two sets.
template<typename T>
inline void sort_moves(T* firstMove, T* lastMove)
inline void sort_moves(T* firstMove, T* lastMove, T** lastPositive)
{
T tmp;
T *p, *d;
@@ -114,9 +114,9 @@ inline void sort_moves(T* firstMove, T* lastMove)
} while (p != d);
// Sort positives and non-positives separately
// Sort just positive scored moves, remaining only when we get there
insertion_sort<T>(firstMove, p);
insertion_sort<T>(p, lastMove);
*lastPositive = p;
}
// Picks up the best move in range [curMove, lastMove), one per cycle.