[libcxx-commits] [libcxx] [libc++] Refactor basic_string::__recommend (PR #162631)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Oct 10 10:02:44 PDT 2025
================
@@ -2344,16 +2346,15 @@ private:
return (__s + (__a - 1)) & ~(__a - 1);
}
enum { __alignment = 8 };
- static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __s) _NOEXCEPT {
- if (__s < __min_cap) {
- return static_cast<size_type>(__min_cap) - 1;
- }
+
+ _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
+ __align_allocation_size(size_type __size) _NOEXCEPT {
----------------
ldionne wrote:
I would add an internal assertion that the `__size` provided here does not fit into the SSO, since that is an expectation of the code. It documents the contract better.
https://github.com/llvm/llvm-project/pull/162631
More information about the libcxx-commits
mailing list