QuickSort: Don't sort a single item, nothing to do

This commit is contained in:
Robin Burchell 2019-05-26 01:41:48 +02:00 committed by Andreas Kling
parent eeab2e8bb5
commit 23a5ce3319
Notes: sideshowbarker 2024-07-19 13:56:45 +09:00

View file

@ -12,7 +12,7 @@ template <typename Iterator, typename LessThan>
void quick_sort(Iterator start, Iterator end, LessThan less_than = is_less_than)
{
int size = end - start;
if (size <= 0)
if (size <= 1)
return;
int pivot_point = size / 2;