[libcxx-commits] [libcxx] [libcxx] Align allocation to match `__set_long_cap` and `__get_long_cap` (PR #90292)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 1 00:23:32 PDT 2024


================
@@ -1959,10 +1960,10 @@ private:
     if (__s < __min_cap) {
       return static_cast<size_type>(__min_cap) - 1;
     }
-    const size_type __boundary = sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : 1;
+    const size_type __boundary = sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : __endian_factor;
     size_type __guess          = __align_it<__boundary>(__s + 1) - 1;
     if (__guess == __min_cap)
-      ++__guess;
+      __guess += 2;
----------------
philnik777 wrote:

Yeah, I think `__endian_factor` would be the right call. Maybe we should rename it into something like `__min_capacity_alignment`, since that's what it basically is? Just a though, not a request for this patch.

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


More information about the libcxx-commits mailing list