[libcxx-commits] [PATCH] D141205: [libcxx] nth_element use introselect to avoid quadratic behavior

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jan 8 08:26:30 PST 2023


Mordante added a comment.

Thanks for working on this. Can you also provide benchmarks to see the effect on the other kinds of data?



================
Comment at: libcxx/include/__algorithm/nth_element.h:104
+        {
+            // fall back to heap select.
+            std::__heap_select<_AlgPolicy, _Compare>(__first, __nth, __last, __comp);
----------------
Can you add comment why this is done? Currently the comment and the code tell the same thing.
For maintainability it would be very good to know why we switch the algorithm.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141205/new/

https://reviews.llvm.org/D141205



More information about the libcxx-commits mailing list