[libcxx-commits] [libcxx] [libcxx] Remove empty ~__no_destroy (PR #89882)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 25 06:47:22 PDT 2024


================
@@ -29,33 +30,23 @@ struct __uninitialized_tag {};
 // initialization using __emplace.
 template <class _Tp>
 struct __no_destroy {
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(__uninitialized_tag) : __dummy_() {
-    if (__libcpp_is_constant_evaluated()) {
-      __dummy_ = char();
-    }
-  }
-  _LIBCPP_HIDE_FROM_ABI ~__no_destroy() {
-    // nothing
-  }
+  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __no_destroy(__uninitialized_tag) {}
 
   template <class... _Args>
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(_Args&&... __args)
-      : __obj_(std::forward<_Args>(__args)...) {}
+  _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(_Args&&... __args) {
----------------
ldionne wrote:

Here we are needlessly initializing the `unsigned char` array before we overwrite it with placement new. We could avoid zero-initializing the array first by dropping the member initializer below.

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


More information about the libcxx-commits mailing list