]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use some more std::arrays. 12839/head
authorDavid Wells <drwells@email.unc.edu>
Sat, 16 Oct 2021 18:32:53 +0000 (14:32 -0400)
committerDavid Wells <drwells@email.unc.edu>
Sat, 16 Oct 2021 18:32:53 +0000 (14:32 -0400)
Incredibly, on my machine with max optimizations, valgrind complains about
unknown instructions with std::vector but does not with std::array.

source/grid/grid_generator.cc

index c15c2a6352277744532d21eec596279d5c3380bd..a494186787c533d4e5ff089da7c4080bea072bd8 100644 (file)
@@ -2564,7 +2564,7 @@ namespace GridGenerator
       }
 
     // calculate deltas and validate input
-    std::vector<Point<spacedim>> delta(dim);
+    std::array<Point<spacedim>, dim> delta;
     for (unsigned int i = 0; i < dim; ++i)
       {
         Assert(repetitions[i] >= 1, ExcInvalidRepetitions(repetitions[i]));
@@ -3077,8 +3077,8 @@ namespace GridGenerator
 
     Assert(spacing.size() == dim, ExcInvalidRepetitionsDimension(dim));
 
-    std::vector<unsigned int> repetitions(dim);
-    double                    delta = std::numeric_limits<double>::max();
+    std::array<unsigned int, dim> repetitions;
+    double                        delta = std::numeric_limits<double>::max();
     for (unsigned int i = 0; i < dim; ++i)
       {
         repetitions[i] = spacing[i].size();
@@ -3192,8 +3192,8 @@ namespace GridGenerator
     // are >= 1, and calculate deltas
     // convert repetitions from double
     // to int by taking the ceiling.
-    std::vector<Point<spacedim>> delta(dim);
-    unsigned int                 repetitions[dim];
+    std::array<Point<spacedim>, dim> delta;
+    std::array<unsigned int, dim>    repetitions;
     for (unsigned int i = 0; i < dim; ++i)
       {
         Assert(holes[i] >= 1,

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.