diff --git a/src/field/field_data.cxx b/src/field/field_data.cxx index 8f6a808482..b54f95ba64 100644 --- a/src/field/field_data.cxx +++ b/src/field/field_data.cxx @@ -189,12 +189,11 @@ void FieldData::addBndryGenerator(FieldGeneratorPtr gen, BndryLoc location) { } FieldGeneratorPtr FieldData::getBndryGenerator(BndryLoc location) { - auto it = bndry_generator.find(location); - if (it == bndry_generator.end()) { - return nullptr; + if (const auto it = bndry_generator.find(location); it != bndry_generator.end()) { + return it->second; } - return it->second; + return nullptr; } Mesh* FieldData::getMesh() const { diff --git a/src/field/field_factory.cxx b/src/field/field_factory.cxx index 1f5984ba48..220597a215 100644 --- a/src/field/field_factory.cxx +++ b/src/field/field_factory.cxx @@ -301,8 +301,7 @@ Field3D FieldFactory::create3D(FieldGeneratorPtr gen, Mesh* localmesh, CELL_LOC }; if (transform_from_field_aligned) { - auto coords = result.getCoordinates(); - if (coords == nullptr) { + if (auto coords = result.getCoordinates(); coords == nullptr) { // Should not lead to issues. If called from the coordinates // constructor, then this is expected, and the result will be // transformed. Otherwise, if the field is used untransformed, @@ -352,8 +351,7 @@ FieldPerp FieldFactory::createPerp(FieldGeneratorPtr gen, Mesh* localmesh, CELL_ }; if (transform_from_field_aligned) { - auto coords = result.getCoordinates(); - if (coords == nullptr) { + if (auto coords = result.getCoordinates(); coords == nullptr) { // Should not lead to issues. If called from the coordinates // constructor, then this is expected, and the result will be // transformed. Otherwise, if the field is used untransformed, @@ -376,8 +374,7 @@ const Options* FieldFactory::findOption(const Options* opt, const std::string& n const Options* result = opt; // Check if name contains a section separator ':' - size_t pos = name.find(':'); - if (pos == std::string::npos) { + if (auto pos = name.find(':'); pos == std::string::npos) { // No separator. Try this section, and then go through parents while (!result->isSet(name)) { @@ -517,8 +514,7 @@ FieldGeneratorPtr FieldFactory::parse(const std::string& input, key = opt->str() + key; // Include options context in key } - auto it = cache.find(key); - if (it != cache.end()) { + if (auto it = cache.find(key); it != cache.end()) { return it->second; } diff --git a/src/mesh/coordinates_accessor.cxx b/src/mesh/coordinates_accessor.cxx index efc27e9715..6967087a0e 100644 --- a/src/mesh/coordinates_accessor.cxx +++ b/src/mesh/coordinates_accessor.cxx @@ -21,8 +21,7 @@ CoordinatesAccessor::CoordinatesAccessor(const Coordinates* coords) { Mesh* mesh = coords->dx.getMesh(); mesh_nz = mesh->LocalNz; - auto search = coords_store.find(coords); - if (search != coords_store.end()) { + if (const auto search = coords_store.find(coords); search != coords_store.end()) { // Found, so get the pointer to the data data = search->second.begin(); return;