Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/xss-common-argsort.h
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,15 @@ X86_SIMD_SORT_INLINE void xss_argsort(const T *arr,
UNUSED(nans_last);

/* early exit for already sorted arrays: float/double with nan never reach here*/
auto comp = descending ? Comparator<vectype, true>::STDSortComparator
: Comparator<vectype, false>::STDSortComparator;
if (std::is_sorted(arr, arr + arrsize, comp)) { return; }
// Pick the scan first so its comparator stays known at compile time.
bool already_sorted = descending
? std::is_sorted(arr, arr + arrsize, [](const T &a, const T &b) {
return Comparator<vectype, true>::STDSortComparator(a, b);
})
: std::is_sorted(arr, arr + arrsize, [](const T &a, const T &b) {
return Comparator<vectype, false>::STDSortComparator(a, b);
});
if (already_sorted) { return; }

#ifdef XSS_COMPILE_OPENMP

Expand Down
Loading