]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix issues found by clang-tidy checks=performance* 5906/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 15 Feb 2018 23:05:55 +0000 (00:05 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 15 Feb 2018 23:07:58 +0000 (00:07 +0100)
examples/step-29/step-29.cc
examples/step-49/step-49.cc
examples/step-9/step-9.cc
source/base/data_out_base.cc
source/dofs/dof_renumbering.cc

index 09bc28a47a5e836bab61e350b40b3edcd668815c..1505344aa614f8339459ada1c896763d7419a40e 100644 (file)
@@ -143,7 +143,7 @@ namespace Step29
   {
   public:
     ParameterReader(ParameterHandler &);
-    void read_parameters(const std::string);
+    void read_parameters(const std::string &);
 
   private:
     void declare_parameters();
@@ -249,7 +249,7 @@ namespace Step29
   // the input file whose filename is provided by the caller. After the call
   // to this function is complete, the <code>prm</code> object can be used to
   // retrieve the values of the parameters read in from the file:
-  void ParameterReader::read_parameters (const std::string parameter_file)
+  void ParameterReader::read_parameters (const std::string &parameter_file)
   {
     declare_parameters();
 
index 4b3eefbfcf7c0e3988c3460fcb18179d88a44839..dd977db64fe36d27b0885addcf704285055c084e 100644 (file)
@@ -171,7 +171,7 @@ void grid_3 ()
   Triangulation<2> triangulation;
   GridGenerator::hyper_cube_with_cylindrical_hole (triangulation, 0.25, 1.0);
 
-  for (const auto cell : triangulation.active_cell_iterators())
+  for (const auto &cell : triangulation.active_cell_iterators())
     {
       for (unsigned int i=0; i<GeometryInfo<2>::vertices_per_cell; ++i)
         {
index c1bd66b9b8821b4ba5ba6f86b0a7385578e0d41c..2878ba8ae5d3eabb9db68a31cff2c7ab27b356ac 100644 (file)
@@ -1109,7 +1109,7 @@ namespace Step9
     active_neighbors.reserve (GeometryInfo<dim>::faces_per_cell *
                               GeometryInfo<dim>::max_children_per_face);
 
-    typename DoFHandler<dim>::active_cell_iterator cell_it(std::get<0>(*cell));
+    const typename DoFHandler<dim>::active_cell_iterator &cell_it(std::get<0>(*cell));
 
     // First initialize the <code>FEValues</code> object, as well as the
     // <code>Y</code> tensor:
@@ -1144,14 +1144,14 @@ namespace Step9
     // neighbors, of course.
     active_neighbors.clear ();
     for (unsigned int face_no=0; face_no<GeometryInfo<dim>::faces_per_cell; ++face_no)
-      if (! std::get<0>(*cell)->at_boundary(face_no))
+      if (! cell_it->at_boundary(face_no))
         {
           // First define an abbreviation for the iterator to the face and
           // the neighbor
           const typename DoFHandler<dim>::face_iterator
-          face = std::get<0>(*cell)->face(face_no);
+          face = cell_it->face(face_no);
           const typename DoFHandler<dim>::cell_iterator
-          neighbor = std::get<0>(*cell)->neighbor(face_no);
+          neighbor = cell_it->neighbor(face_no);
 
           // Then check whether the neighbor is active. If it is, then it
           // is on the same level or one level coarser (if we are not in
@@ -1194,7 +1194,7 @@ namespace Step9
                   // as an internal error. We therefore use a predefined
                   // exception class to throw here.
                   Assert (neighbor_child->neighbor(face_no==0 ? 1 : 0)
-                          ==std::get<0>(*cell),ExcInternalError());
+                          ==cell_it,ExcInternalError());
 
                   // If the check succeeded, we push the active neighbor
                   // we just found to the stack we keep:
@@ -1205,7 +1205,7 @@ namespace Step9
                 // `behind' the subfaces of the current face
                 for (unsigned int subface_no=0; subface_no<face->n_children(); ++subface_no)
                   active_neighbors.push_back (
-                    std::get<0>(*cell)->neighbor_child_on_subface(face_no,subface_no));
+                    cell_it->neighbor_child_on_subface(face_no,subface_no));
             }
         }
 
@@ -1307,7 +1307,7 @@ namespace Step9
     // at the second element of the pair of iterators, which requires
     // slightly awkward syntax but is not otherwise particularly
     // difficult:
-    *(std::get<1>(*cell)) = (std::pow(std::get<0>(*cell)->diameter(),
+    *(std::get<1>(*cell)) = (std::pow(cell_it->diameter(),
                                       1+1.0*dim/2) *
                              std::sqrt(gradient.norm_square()));
 
index 3272e80f115ac6520a8609196ca1306e8a915d5d..65183d71c60720b1ccde784b1e2ec30082782424 100644 (file)
@@ -5924,14 +5924,14 @@ namespace DataOutBase
     const float angle_factor = 3.14159265f / 180.f;
 
     // (I) rotate the camera to the chosen polar angle
-    camera_position_temp[1] = cos(angle_factor * flags.polar_angle) * camera_position[1] - sin(angle_factor * flags.polar_angle) * camera_position[2];
-    camera_position_temp[2] = sin(angle_factor * flags.polar_angle) * camera_position[1] + cos(angle_factor * flags.polar_angle) * camera_position[2];
+    camera_position_temp[1] = std::cos(angle_factor * flags.polar_angle) * camera_position[1] - std::sin(angle_factor * flags.polar_angle) * camera_position[2];
+    camera_position_temp[2] = std::sin(angle_factor * flags.polar_angle) * camera_position[1] + std::cos(angle_factor * flags.polar_angle) * camera_position[2];
 
-    camera_direction_temp[1] = cos(angle_factor * flags.polar_angle) * camera_direction[1] - sin(angle_factor * flags.polar_angle) * camera_direction[2];
-    camera_direction_temp[2] = sin(angle_factor * flags.polar_angle) * camera_direction[1] + cos(angle_factor * flags.polar_angle) * camera_direction[2];
+    camera_direction_temp[1] = std::cos(angle_factor * flags.polar_angle) * camera_direction[1] - std::sin(angle_factor * flags.polar_angle) * camera_direction[2];
+    camera_direction_temp[2] = std::sin(angle_factor * flags.polar_angle) * camera_direction[1] + std::cos(angle_factor * flags.polar_angle) * camera_direction[2];
 
-    camera_horizontal_temp[1] = cos(angle_factor * flags.polar_angle) * camera_horizontal[1] - sin(angle_factor * flags.polar_angle) * camera_horizontal[2];
-    camera_horizontal_temp[2] = sin(angle_factor * flags.polar_angle) * camera_horizontal[1] + cos(angle_factor * flags.polar_angle) * camera_horizontal[2];
+    camera_horizontal_temp[1] = std::cos(angle_factor * flags.polar_angle) * camera_horizontal[1] - std::sin(angle_factor * flags.polar_angle) * camera_horizontal[2];
+    camera_horizontal_temp[2] = std::sin(angle_factor * flags.polar_angle) * camera_horizontal[1] + std::cos(angle_factor * flags.polar_angle) * camera_horizontal[2];
 
     camera_position[1] = camera_position_temp[1];
     camera_position[2] = camera_position_temp[2];
@@ -5943,14 +5943,14 @@ namespace DataOutBase
     camera_horizontal[2] = camera_horizontal_temp[2];
 
     // (II) rotate the camera to the chosen azimuth angle
-    camera_position_temp[0] = cos(angle_factor * flags.azimuth_angle) * camera_position[0] - sin(angle_factor * flags.azimuth_angle) * camera_position[1];
-    camera_position_temp[1] = sin(angle_factor * flags.azimuth_angle) * camera_position[0] + cos(angle_factor * flags.azimuth_angle) * camera_position[1];
+    camera_position_temp[0] = std::cos(angle_factor * flags.azimuth_angle) * camera_position[0] - std::sin(angle_factor * flags.azimuth_angle) * camera_position[1];
+    camera_position_temp[1] = std::sin(angle_factor * flags.azimuth_angle) * camera_position[0] + std::cos(angle_factor * flags.azimuth_angle) * camera_position[1];
 
-    camera_direction_temp[0] = cos(angle_factor * flags.azimuth_angle) * camera_direction[0] - sin(angle_factor * flags.azimuth_angle) * camera_direction[1];
-    camera_direction_temp[1] = sin(angle_factor * flags.azimuth_angle) * camera_direction[0] + cos(angle_factor * flags.azimuth_angle) * camera_direction[1];
+    camera_direction_temp[0] = std::cos(angle_factor * flags.azimuth_angle) * camera_direction[0] - std::sin(angle_factor * flags.azimuth_angle) * camera_direction[1];
+    camera_direction_temp[1] = std::sin(angle_factor * flags.azimuth_angle) * camera_direction[0] + std::cos(angle_factor * flags.azimuth_angle) * camera_direction[1];
 
-    camera_horizontal_temp[0] = cos(angle_factor * flags.azimuth_angle) * camera_horizontal[0] - sin(angle_factor * flags.azimuth_angle) * camera_horizontal[1];
-    camera_horizontal_temp[1] = sin(angle_factor * flags.azimuth_angle) * camera_horizontal[0] + cos(angle_factor * flags.azimuth_angle) * camera_horizontal[1];
+    camera_horizontal_temp[0] = std::cos(angle_factor * flags.azimuth_angle) * camera_horizontal[0] - std::sin(angle_factor * flags.azimuth_angle) * camera_horizontal[1];
+    camera_horizontal_temp[1] = std::sin(angle_factor * flags.azimuth_angle) * camera_horizontal[0] + std::cos(angle_factor * flags.azimuth_angle) * camera_horizontal[1];
 
     camera_position[0] = camera_position_temp[0];
     camera_position[1] = camera_position_temp[1];
@@ -5965,8 +5965,8 @@ namespace DataOutBase
     camera_position[0] = x_min + .5 * x_dimension;
     camera_position[1] = y_min + .5 * y_dimension;
 
-    camera_position[0] += (z_min + 2. * z_dimension) * sin(angle_factor * flags.polar_angle) * sin(angle_factor * flags.azimuth_angle);
-    camera_position[1] -= (z_min + 2. * z_dimension) * sin(angle_factor * flags.polar_angle) * cos(angle_factor * flags.azimuth_angle);
+    camera_position[0] += (z_min + 2. * z_dimension) * std::sin(angle_factor * flags.polar_angle) * std::sin(angle_factor * flags.azimuth_angle);
+    camera_position[1] -= (z_min + 2. * z_dimension) * std::sin(angle_factor * flags.polar_angle) * std::cos(angle_factor * flags.azimuth_angle);
 
 
 // determine the bounding box on the projection plane
index aba4838358ed278a459e588fa81fbaac0ac67a94..6948c90a8a6d5b914d6bf0f7bb85c02817094fed 100644 (file)
@@ -1299,7 +1299,7 @@ namespace DoFRenumbering
         = dynamic_cast<const parallel::Triangulation<dim>*>
           (&dof_handler.get_triangulation()))
       {
-        const std::vector<types::global_dof_index>
+        const std::vector<types::global_dof_index> &
         n_locally_owned_dofs_per_processor = dof_handler.n_locally_owned_dofs_per_processor();
         my_starting_index = std::accumulate (n_locally_owned_dofs_per_processor.begin(),
                                              n_locally_owned_dofs_per_processor.begin()

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.