From e36b25987bced5349d99c464c1d39ed3c1e0f280 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Fri, 15 Mar 2024 10:02:57 +0100 Subject: [PATCH] dealii::Vector: Simplify reset of vector size --- include/deal.II/lac/vector.templates.h | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/include/deal.II/lac/vector.templates.h b/include/deal.II/lac/vector.templates.h index c46c3b6cc0..21707800d5 100644 --- a/include/deal.II/lac/vector.templates.h +++ b/include/deal.II/lac/vector.templates.h @@ -1092,27 +1092,15 @@ Vector::do_reinit(const size_type new_size, const bool omit_zeroing_entries, const bool reset_partitioner) { - if (new_size <= size()) + if (new_size == 0) { - if (new_size == 0) - { - values.clear(); - } - else - { - values.resize_fast(new_size); - if (!omit_zeroing_entries) - values.fill(); - } + values.clear(); } else { - // otherwise size() < new_size and we must allocate - AlignedVector new_values; - new_values.resize_fast(new_size); + values.resize_fast(new_size); if (!omit_zeroing_entries) - new_values.fill(); - new_values.swap(values); + values.fill(); } if (reset_partitioner) -- 2.39.5