[libcxx-commits] [PATCH] D113413: Add introsort to avoid O(n^2) behavior and a benchmark for adversarial quick sort input.

Nilay Vaish via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 17 19:54:28 PST 2021


nilayvaish 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.
Noted.  Will send a diff later today.


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