[libcxx-commits] [libcxx] [libc++] Optimize {set, map}::{lower, upper}_bound (PR #161366)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 1 08:25:03 PDT 2025


================
@@ -849,8 +849,10 @@ public:
   }
 #  endif // _LIBCPP_STD_VER >= 20
 
-  _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
-  _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
+  _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.__lower_bound_unique(__k); }
+  _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const {
+    return __tree_.__lower_bound_unique(__k);
+  }
 #  if _LIBCPP_STD_VER >= 14
   template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
   _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
----------------
ldionne wrote:

After the renaming, we need a comment explaining why this calls `__lower_bound_multi` from a non-multi container. Same below.

https://github.com/llvm/llvm-project/pull/161366


More information about the libcxx-commits mailing list