From e797e18c77154b9d779c11cefd7fe073bc96b2ec Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 7 Dec 2024 17:45:08 -0500 Subject: [PATCH] AlignedVector: Switch to placement new in two codepaths. Using placement new here is, for scalar types, the same as assignment. For non-scalar types, this change results in fewer operations since instead of doing default construction followed by assignment we now just use the copy constructor. --- include/deal.II/base/aligned_vector.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/include/deal.II/base/aligned_vector.h b/include/deal.II/base/aligned_vector.h index 4ee1522094..973277db05 100644 --- a/include/deal.II/base/aligned_vector.h +++ b/include/deal.II/base/aligned_vector.h @@ -1542,10 +1542,7 @@ AlignedVector::push_back(const T in_data) Assert(used_elements_end <= allocated_elements_end, ExcInternalError()); if (used_elements_end == allocated_elements_end) reserve(std::max(2 * capacity(), static_cast(16))); - if (std::is_trivial_v == false) - new (used_elements_end++) T(in_data); - else - *used_elements_end++ = in_data; + new (used_elements_end++) T(in_data); } @@ -1580,11 +1577,7 @@ AlignedVector::insert_back(ForwardIterator begin, ForwardIterator end) const size_type old_size = size(); reserve(old_size + (end - begin)); for (; begin != end; ++begin, ++used_elements_end) - { - if (std::is_trivial_v == false) - new (used_elements_end) T; - *used_elements_end = *begin; - } + new (used_elements_end) T(*begin); } -- 2.39.5