[libc-commits] [libc] [llvm] [libc] Improve qsort (PR #120450)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Wed Dec 18 17:52:30 PST 2024
================
@@ -19,13 +19,12 @@ LLVM_LIBC_FUNCTION(void, qsort_r,
(void *array, size_t array_size, size_t elem_size,
int (*compare)(const void *, const void *, void *),
void *arg)) {
- if (array == nullptr || array_size == 0 || elem_size == 0)
- return;
- internal::Comparator c(compare, arg);
- auto arr = internal::Array(reinterpret_cast<uint8_t *>(array), array_size,
- elem_size, c);
- internal::sort(arr);
+ internal::unstable_sort(
+ array, array_size, elem_size,
+ [compare, arg](const void *a, const void *b) noexcept -> bool {
----------------
SchrodingerZhu wrote:
@michaelrj-google I think the `is_less` function @Voultapher passed in is actually a wrapper of the raw integer function. So, calling it `is_less` should be good.
https://github.com/llvm/llvm-project/pull/120450
More information about the libc-commits
mailing list