[libcxx-commits] [PATCH] D140824: [libc++] Forward ranges::sort to instantiations in the dylib
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 1 09:24:42 PST 2023
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.
This is awesome! This is a big simplification, thanks for working on it!
================
Comment at: libcxx/include/__algorithm/sort.h:110-111
+template <class _AlgPolicy, class _Comp, class _ForwardIterator>
+_LIBCPP_HIDE_FROM_ABI unsigned __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
+ _ForwardIterator __x4, _ForwardIterator __x5, _Comp __comp) {
using _Ops = _IterOps<_AlgPolicy>;
----------------
================
Comment at: libcxx/include/__algorithm/sort.h:841-842
template <class _WrappedComp, class _RandomAccessIterator>
-_LIBCPP_HIDDEN void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) {
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- difference_type __depth_limit = 2 * std::__log2i(__last - __first);
-
- using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;
- using _AlgPolicy = typename _Unwrap::_AlgPolicy;
- using _Compare = typename _Unwrap::_Comp;
- _Compare __comp = _Unwrap::__get_comp(__wrapped_comp);
- // Only use bitset partitioning for arithmetic types. We should also check
- // that the default comparator is in use so that we are sure that there are no
- // branches in the comparator.
- std::__introsort<_AlgPolicy,
- _Compare,
- _RandomAccessIterator,
- __use_branchless_sort<_Compare, _RandomAccessIterator>::value>(
- __first, __last, __comp, __depth_limit);
-}
-
-template <class _Compare, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY void __sort(_Tp** __first, _Tp** __last, __less<_Tp*>&) {
- __less<uintptr_t> __comp;
- std::__sort<__less<uintptr_t>&, uintptr_t*>((uintptr_t*)__first, (uintptr_t*)__last, __comp);
-}
+void __sort(_RandomAccessIterator, _RandomAccessIterator, _WrappedComp);
----------------
================
Comment at: libcxx/src/algorithm.cpp:34-35
template void __sort<__less<short>&, short*>(short*, short*, __less<short>&);
-template void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
+template void
+__sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
template void __sort<__less<int>&, int*>(int*, int*, __less<int>&);
----------------
I would keep them aligned cause it's just a list of things, and use `// clang-format off` if needed.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140824/new/
https://reviews.llvm.org/D140824
More information about the libcxx-commits
mailing list