Skip to content

Commit 315a922

Browse files
committed
Simplify __alloc() and __dealloc() in __utility/small_buffer.h
1 parent f05f144 commit 315a922

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

libcxx/include/__utility/small_buffer.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,14 @@ class __small_buffer {
6666
if constexpr (__fits_in_buffer<_Stored>) {
6767
return std::launder(reinterpret_cast<_Stored*>(__buffer_));
6868
} else {
69-
# ifdef _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
70-
byte* __allocation = static_cast<byte*>(::operator new[](sizeof(_Stored), align_val_t{alignof(_Stored)}));
71-
std::construct_at(reinterpret_cast<byte**>(__buffer_), __allocation);
72-
return std::launder(reinterpret_cast<_Stored*>(__allocation));
73-
# else
74-
return static_cast<_Stored*>(std::__libcpp_allocate(_BufferSize * sizeof(byte), _LIBCPP_ALIGNOF(byte)));
75-
# endif // _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
69+
return static_cast<_Stored*>(std::__libcpp_allocate(_BufferSize * sizeof(byte), alignof(_Stored)));
7670
}
7771
}
7872

7973
template <class _Stored>
8074
_LIBCPP_HIDE_FROM_ABI void __dealloc() noexcept {
8175
if constexpr (!__fits_in_buffer<_Stored>)
82-
# ifdef _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION
83-
::operator delete[](*reinterpret_cast<void**>(__buffer_), sizeof(_Stored), align_val_t{alignof(_Stored)});
84-
# else
85-
std::__libcpp_deallocate((void*)__buffer_, _BufferSize * sizeof(byte), _LIBCPP_ALIGNOF(_Stored));
86-
# endif // _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION
76+
std::__libcpp_deallocate((void*)__buffer_, _BufferSize * sizeof(byte), alignof(_Stored));
8777
}
8878

8979
template <class _Stored, class... _Args>

0 commit comments

Comments
 (0)