[libc-commits] [libc] [llvm] [libc] Improve qsort (PR #120450)
Lukas Bergdoll via libc-commits
libc-commits at lists.llvm.org
Thu Dec 19 09:05:40 PST 2024
================
@@ -27,11 +27,46 @@
namespace LIBC_NAMESPACE_DECL {
namespace internal {
+template <typename A, typename F> void sort_inst(A &array, const F &is_less) {
#if LIBC_QSORT_IMPL == LIBC_QSORT_QUICK_SORT
-constexpr auto sort = quick_sort;
+ quick_sort(array, is_less);
#elif LIBC_QSORT_IMPL == LIBC_QSORT_HEAP_SORT
-constexpr auto sort = heap_sort;
+ heap_sort(array, is_less);
#endif
+}
+
+template <typename F>
+void unstable_sort(void *array, size_t array_len, size_t elem_size,
+ const F &is_less) {
+ if (array == nullptr || array_len == 0 || elem_size == 0) {
+ return;
+ }
+
+ uint8_t *array_base = reinterpret_cast<uint8_t *>(array);
----------------
Voultapher wrote:
No longer relevant.
https://github.com/llvm/llvm-project/pull/120450
More information about the libc-commits
mailing list