From c5b071b4f05b8f2f174960b068a47ca1f4060fdd Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Fri, 16 Feb 2018 00:05:55 +0100 Subject: [PATCH] Fix issues found by clang-tidy checks=performance* --- examples/step-29/step-29.cc | 4 ++-- examples/step-49/step-49.cc | 2 +- examples/step-9/step-9.cc | 14 +++++++------- source/base/data_out_base.cc | 28 ++++++++++++++-------------- source/dofs/dof_renumbering.cc | 2 +- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/examples/step-29/step-29.cc b/examples/step-29/step-29.cc index 09bc28a47a..1505344aa6 100644 --- a/examples/step-29/step-29.cc +++ b/examples/step-29/step-29.cc @@ -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 prm 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 ¶meter_file) { declare_parameters(); diff --git a/examples/step-49/step-49.cc b/examples/step-49/step-49.cc index 4b3eefbfcf..dd977db64f 100644 --- a/examples/step-49/step-49.cc +++ b/examples/step-49/step-49.cc @@ -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::vertices_per_cell; ++i) { diff --git a/examples/step-9/step-9.cc b/examples/step-9/step-9.cc index c1bd66b9b8..2878ba8ae5 100644 --- a/examples/step-9/step-9.cc +++ b/examples/step-9/step-9.cc @@ -1109,7 +1109,7 @@ namespace Step9 active_neighbors.reserve (GeometryInfo::faces_per_cell * GeometryInfo::max_children_per_face); - typename DoFHandler::active_cell_iterator cell_it(std::get<0>(*cell)); + const typename DoFHandler::active_cell_iterator &cell_it(std::get<0>(*cell)); // First initialize the FEValues object, as well as the // Y tensor: @@ -1144,14 +1144,14 @@ namespace Step9 // neighbors, of course. active_neighbors.clear (); for (unsigned int face_no=0; face_no::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::face_iterator - face = std::get<0>(*cell)->face(face_no); + face = cell_it->face(face_no); const typename DoFHandler::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_non_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())); diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index 3272e80f11..65183d71c6 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -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 diff --git a/source/dofs/dof_renumbering.cc b/source/dofs/dof_renumbering.cc index aba4838358..6948c90a8a 100644 --- a/source/dofs/dof_renumbering.cc +++ b/source/dofs/dof_renumbering.cc @@ -1299,7 +1299,7 @@ namespace DoFRenumbering = dynamic_cast*> (&dof_handler.get_triangulation())) { - const std::vector + const std::vector & 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() -- 2.39.5