From a34347e42f60db40815b87d47e742e0e65f6d51c Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Mon, 13 Jun 2022 08:19:52 +0200 Subject: [PATCH] Fixing 'The scope of the variable can be reduced. --- Applications/FileIO/CsvInterface.cpp | 2 +- Applications/FileIO/TetGenInterface.cpp | 2 +- MeshLib/IO/Legacy/MeshIO.cpp | 8 ++++---- ProcessLib/ComponentTransport/LookupTable.cpp | 5 +---- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Applications/FileIO/CsvInterface.cpp b/Applications/FileIO/CsvInterface.cpp index 5536da166ab..19636a82ee6 100644 --- a/Applications/FileIO/CsvInterface.cpp +++ b/Applications/FileIO/CsvInterface.cpp @@ -201,11 +201,11 @@ int CsvInterface::readPoints(std::ifstream& in, char delim, continue; } - std::array<double, 3> point{}; it = fields.begin(); try { std::advance(it, column_advance[0]); + std::array<double, 3> point{}; point[order[0]] = std::stod(*it); std::advance(it, column_advance[1]); point[order[1]] = std::stod(*it); diff --git a/Applications/FileIO/TetGenInterface.cpp b/Applications/FileIO/TetGenInterface.cpp index aef1f947b3a..4d94dff7e1f 100644 --- a/Applications/FileIO/TetGenInterface.cpp +++ b/Applications/FileIO/TetGenInterface.cpp @@ -161,11 +161,11 @@ bool TetGenInterface::parseSmeshFacets( "meshes."); return false; } - std::vector<std::size_t> point_ids; const std::size_t point_field_size = (_boundary_markers) ? nPoints + 1 : nPoints; if (point_fields.size() > point_field_size) { + std::vector<std::size_t> point_ids; for (std::size_t j(0); j < nPoints; ++j) { point_ids.push_back( diff --git a/MeshLib/IO/Legacy/MeshIO.cpp b/MeshLib/IO/Legacy/MeshIO.cpp index 3ab255bf7f8..3eb1c38874c 100644 --- a/MeshLib/IO/Legacy/MeshIO.cpp +++ b/MeshLib/IO/Legacy/MeshIO.cpp @@ -54,12 +54,12 @@ MeshLib::Mesh* MeshIO::loadMeshFromFile(const std::string& file_name) std::string line_string; getline(in, line_string); - std::vector<MeshLib::Node*> nodes; - std::vector<MeshLib::Element*> elements; - std::vector<std::size_t> materials; - if (line_string.find("#FEM_MSH") != std::string::npos) // OGS mesh file { + std::vector<MeshLib::Node*> nodes; + std::vector<MeshLib::Element*> elements; + std::vector<std::size_t> materials; + while (!in.eof()) { getline(in, line_string); diff --git a/ProcessLib/ComponentTransport/LookupTable.cpp b/ProcessLib/ComponentTransport/LookupTable.cpp index 5e3c749ab0d..8ef571979ac 100644 --- a/ProcessLib/ComponentTransport/LookupTable.cpp +++ b/ProcessLib/ComponentTransport/LookupTable.cpp @@ -134,8 +134,6 @@ void LookupTable::lookup(std::vector<GlobalVector*> const& x, std::size_t LookupTable::getTableEntryID( std::vector<double> const& entry_input) const { - std::vector<std::size_t> temp_vec; - std::vector<std::size_t> intersected_vec = /// point_id_groups stores indices where the elements equal to the given /// value. @@ -151,10 +149,9 @@ std::size_t LookupTable::getTableEntryID( input_fields[i].point_id_groups[BaseLib::findIndex( input_fields[i].seed_points, entry_input[i])]; - temp_vec = intersection(intersected_vec, vec); + auto temp_vec = intersection(intersected_vec, vec); std::swap(intersected_vec, temp_vec); - temp_vec.clear(); } return intersected_vec[0]; -- GitLab