[libcxx-commits] [libcxx] [libc++] __key_equiv is sometimes 2x expensive (PR #175087)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 12 00:38:01 PST 2026
================
@@ -29,9 +29,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// unique
+// For this unchecked algorithm, __pred does not need to be an equivalence relation.
template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 std::pair<_Iter, _Iter>
-__unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
+__unchecked_unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
----------------
philnik777 wrote:
I'm not a huge fan of the naming either. To me this currently implies that we simply don't check some semantic requirement/precondition, which is _not_ the case. However, I do agree with @halbi2 that it shouldn't be `__unique`, since that implies the same semantics as `{std,ranges}::unique`, which we don't want. This function actually has different semantics, or at least preconditions. WDYT about `__unique_sorted_range`?
https://github.com/llvm/llvm-project/pull/175087
More information about the libcxx-commits
mailing list