diff --git a/src/search.cpp b/src/search.cpp index 8dc1f85d9e5..bfade6d09b5 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -394,7 +394,7 @@ namespace { } // Sort the PV lines searched so far and update the GUI - sort(RootMoves.begin(), RootMoves.begin() + PVIdx); + sort(RootMoves.begin(), RootMoves.begin() + PVIdx + 1); sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl; } diff --git a/src/types.h b/src/types.h index 1842eb2a3ea..9b36fd89fde 100644 --- a/src/types.h +++ b/src/types.h @@ -490,15 +490,15 @@ inline const std::string square_to_string(Square s) { /// Our insertion sort implementation, works with pointers and iterators and is /// guaranteed to be stable, as is needed. template -void sort(K first, K last) +void sort(K begin, K end) { T tmp; K p, q; - for (p = first + 1; p < last; p++) + for (p = begin + 1; p < end; p++) { tmp = *p; - for (q = p; q != first && *(q-1) < tmp; --q) + for (q = p; q != begin && *(q-1) < tmp; --q) *q = *(q-1); *q = tmp; }