]> https://gitweb.dealii.org/ - dealii.git/commitdiff
dealii::Vector: Simplify reset of vector size
authorMartin Kronbichler <martin.kronbichler@rub.de>
Fri, 15 Mar 2024 09:02:57 +0000 (10:02 +0100)
committerMartin Kronbichler <martin.kronbichler@rub.de>
Fri, 15 Mar 2024 09:03:37 +0000 (10:03 +0100)
include/deal.II/lac/vector.templates.h

index c46c3b6cc0b82b1c6b427146bbca533dfe58929e..21707800d5a267535dc542a4efba324a8a5dd332 100644 (file)
@@ -1092,27 +1092,15 @@ Vector<Number>::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<Number> 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)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.