[libcxx-commits] [libcxx] [libc++] Replace __resize_default_init with resize_and_overwrite (PR #157121)
James Y Knight via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Sep 19 09:20:51 PDT 2025
jyknight wrote:
The removal of __resize_default_init and __append_default_init (originally added in 01a87ef88b77034ab6a9ea7bc9da24fb380e91e8 back in 2018), causes a performance regression for Google, as we use those widely to avoid unnecessary writes for overwrite.
The uses are guarded by a presence-check, so it's not a _functional_ breakage, but it's critical for performance. Happily, C++23 has standardized string::resize_and_overwrite, but that's not available under C++20. That makes the _timing_ of the removal of these nonstandard APIs unfortunate, as we're left with no workable option at the moment.
You can see the current usage in [Google's ABSL library](https://github.com/abseil/abseil-cpp/blob/master/absl/strings/internal/resize_uninitialized.h)
Could we add back these APIs? Or else maybe make a version of resize_and_overwrite available (under a non-standard name?) to code which is built before C++23? If not, I'll need to carry a local patch to libc++ to re-add this functionality, or maybe use a similar horrible-hack that facebook's Folly library uses to achieve the same goal, https://github.com/facebook/folly/blob/c82ea832857119a27f4a56d37f28086fac06e63a/folly/memory/UninitializedMemoryHacks.h#L171
https://github.com/llvm/llvm-project/pull/157121
More information about the libcxx-commits
mailing list