Update pdqsort to recent version (#10171)

This commit is contained in:
Ivan 2020-04-11 14:16:14 +03:00 committed by GitHub
parent 67235834b3
commit 19bb2976b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,10 +125,8 @@ namespace pdqsort_detail {
typedef typename std::iterator_traits<Iter>::value_type T; typedef typename std::iterator_traits<Iter>::value_type T;
if (begin == end) return true; if (begin == end) return true;
int limit = 0; std::size_t limit = 0;
for (Iter cur = begin + 1; cur != end; ++cur) { for (Iter cur = begin + 1; cur != end; ++cur) {
if (limit > partial_insertion_sort_limit) return false;
Iter sift = cur; Iter sift = cur;
Iter sift_1 = cur - 1; Iter sift_1 = cur - 1;
@ -142,6 +140,8 @@ namespace pdqsort_detail {
*sift = PDQSORT_PREFER_MOVE(tmp); *sift = PDQSORT_PREFER_MOVE(tmp);
limit += cur - sift; limit += cur - sift;
} }
if (limit > partial_insertion_sort_limit) return false;
} }
return true; return true;
@ -275,7 +275,7 @@ namespace pdqsort_detail {
} }
int l_size = 0, r_size = 0; int l_size = 0, r_size = 0;
int unknown_left = (last - first) - ((num_r || num_l) ? block_size : 0); int unknown_left = (int)(last - first) - ((num_r || num_l) ? block_size : 0);
if (num_r) { if (num_r) {
// Handle leftover block by assigning the unknown elements to the other block. // Handle leftover block by assigning the unknown elements to the other block.
l_size = unknown_left; l_size = unknown_left;