[libcxx-commits] [PATCH] D113413: Add introsort to avoid O(n^2) behavior and a benchmark for adversarial quick sort input.
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Nov 17 19:58:06 PST 2021
Quuxplusone added inline comments.
================
Comment at: libcxx/include/__algorithm/sort.h:477
+ difference_type __depth_limit = 2 * __log2i(__last - __first);
+ __introsort(__first, __last, __comp, __depth_limit);
+}
----------------
Quuxplusone wrote:
> This line needs to use `_VSTD::__introsort` (ADL-proofing — hmm, how did this pass `robust_against_adl.pass.cpp`? I should investigate).
> Also, it needs to use `_Comp_ref<_Compare>` instead of making a copy of `__comp`.
> @nilayvaish, please hunt through the rest of this patch to see if there are any other similar cases. (I did not look.)
>
> I will investigate adding a new test along the lines of `algorithms/robust_*.cpp` to verify that we never accidentally copy comparators or predicates.
Actually, nvm, I got nerdsniped into taking a look myself: D114133
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113413/new/
https://reviews.llvm.org/D113413
More information about the libcxx-commits
mailing list