From c50362629404dfec80431de99e9d76b794d8e981 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 11 Nov 2021 22:25:33 +0100 Subject: [PATCH] ... --- Base/Math/FourierTransform.cpp | 7 +++---- Sample/HardParticle/PolyhedralComponents.cpp | 2 +- Sample/HardParticle/Polyhedron.cpp | 2 +- Sample/HardParticle/Prism.cpp | 2 +- Sample/Multilayer/Layer.cpp | 2 +- Sample/Scattering/IBornFF.cpp | 4 +--- Sample/Scattering/IFormFactor.cpp | 2 +- Sample/SoftParticle/FormFactorSphereLogNormalRadius.cpp | 4 ++-- Sample/StandardSamples/FeNiBilayerBuilder.cpp | 2 +- .../StandardSamples/MultiLayerWithNCRoughnessBuilder.cpp | 2 +- Tests/Unit/Base/FileSystemUtilsTest.cpp | 2 +- Tests/Unit/Param/DistributionHandlerTest.cpp | 3 +-- Tests/Unit/Param/INodeTest.cpp | 5 +++-- Tests/Unit/Param/RangedDistributionTest.cpp | 2 +- 14 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Base/Math/FourierTransform.cpp b/Base/Math/FourierTransform.cpp index 096e6278a72..69bb3603357 100644 --- a/Base/Math/FourierTransform.cpp +++ b/Base/Math/FourierTransform.cpp @@ -33,13 +33,12 @@ void FourierTransform::Workspace::clear() h_src = 0; w_src = 0; - if (in_src) - delete[] in_src; - in_src = 0; + delete[] in_src; + in_src = nullptr; if (out_fftw) fftw_free((fftw_complex*)out_fftw); - out_fftw = 0; + out_fftw = nullptr; if (p_forw_src != nullptr) fftw_destroy_plan(p_forw_src); diff --git a/Sample/HardParticle/PolyhedralComponents.cpp b/Sample/HardParticle/PolyhedralComponents.cpp index 5052ba26bbc..f17fd0d37d1 100644 --- a/Sample/HardParticle/PolyhedralComponents.cpp +++ b/Sample/HardParticle/PolyhedralComponents.cpp @@ -144,7 +144,7 @@ PolyhedralFace::PolyhedralFace(const std::vector<R3>& V, bool _sym_S2) : sym_S2( size_t jj = (j + 1) % NV; if ((V[j] - V[jj]).mag() < 1e-14 * m_radius_2d) continue; // distance too short -> skip this edge - edges.push_back(PolyhedralEdge(V[j], V[jj])); + edges.emplace_back(V[j], V[jj]); } size_t NE = edges.size(); if (NE < 3) diff --git a/Sample/HardParticle/Polyhedron.cpp b/Sample/HardParticle/Polyhedron.cpp index bcdf71f46fb..d162a4d142f 100644 --- a/Sample/HardParticle/Polyhedron.cpp +++ b/Sample/HardParticle/Polyhedron.cpp @@ -54,7 +54,7 @@ Polyhedron::Polyhedron(const PolyhedralTopology& topology, double z_bottom, corners.push_back(vertices[i]); if (PolyhedralFace::diameter(corners) <= 1e-14 * diameter) continue; // skip ridiculously small face - m_faces.push_back(PolyhedralFace(corners, tf.symmetry_S2)); + m_faces.emplace_back(corners, tf.symmetry_S2); } if (m_faces.size() < 4) throw std::logic_error("Less than four non-vanishing faces"); diff --git a/Sample/HardParticle/Prism.cpp b/Sample/HardParticle/Prism.cpp index 8b63b4961ca..2dd4a56b76e 100644 --- a/Sample/HardParticle/Prism.cpp +++ b/Sample/HardParticle/Prism.cpp @@ -30,7 +30,7 @@ Prism::Prism(bool symmetry_Ci, double height, const std::vector<R3>& vertices) } try { - m_base = std::unique_ptr<PolyhedralFace>(new PolyhedralFace(vertices, symmetry_Ci)); + m_base = std::make_unique_ptr<PolyhedralFace>(vertices, symmetry_Ci); } catch (std::invalid_argument& e) { throw std::invalid_argument(std::string("Invalid parameterization of Prism: ") + e.what()); } catch (std::logic_error& e) { diff --git a/Sample/Multilayer/Layer.cpp b/Sample/Multilayer/Layer.cpp index 628b4969fa3..13e8d30b869 100644 --- a/Sample/Multilayer/Layer.cpp +++ b/Sample/Multilayer/Layer.cpp @@ -54,7 +54,7 @@ std::vector<const ParticleLayout*> Layer::layouts() const std::vector<const INode*> Layer::getChildren() const { std::vector<const INode*> result; - for (auto layout : m_layouts) + for (auto* layout : m_layouts) result.push_back(layout); return result; } diff --git a/Sample/Scattering/IBornFF.cpp b/Sample/Scattering/IBornFF.cpp index 6dd3283197f..7e0548badc1 100644 --- a/Sample/Scattering/IBornFF.cpp +++ b/Sample/Scattering/IBornFF.cpp @@ -54,9 +54,7 @@ double IBornFF::topZ(const IRotation& rotation) const bool IBornFF::canSliceAnalytically(const IRotation& rot) const { - if (rot.zInvariant()) - return true; - return false; + return rot.zInvariant(); } Eigen::Matrix2cd IBornFF::evaluate_for_q_pol(C3 q) const diff --git a/Sample/Scattering/IFormFactor.cpp b/Sample/Scattering/IFormFactor.cpp index b2399984378..3236a227183 100644 --- a/Sample/Scattering/IFormFactor.cpp +++ b/Sample/Scattering/IFormFactor.cpp @@ -81,7 +81,7 @@ std::string IFormFactor::pythonConstructor() const { std::vector<std::pair<double, std::string>> arguments; for (size_t i = 0; i < m_nodeMeta.paraMeta.size(); i++) - arguments.push_back({m_P[i], m_nodeMeta.paraMeta[i].unit}); + arguments.emplace_back(m_P[i], m_nodeMeta.paraMeta[i].unit); return Py::Fmt::printFunction(className(), arguments); } diff --git a/Sample/SoftParticle/FormFactorSphereLogNormalRadius.cpp b/Sample/SoftParticle/FormFactorSphereLogNormalRadius.cpp index 43dc81935d6..178e3334143 100644 --- a/Sample/SoftParticle/FormFactorSphereLogNormalRadius.cpp +++ b/Sample/SoftParticle/FormFactorSphereLogNormalRadius.cpp @@ -64,10 +64,10 @@ std::string FormFactorSphereLogNormalRadius::pythonConstructor() const { std::vector<std::pair<std::variant<double, int>, std::string>> arguments; for (size_t i = 0; i < m_nodeMeta.paraMeta.size(); i++) - arguments.push_back({m_P[i], m_nodeMeta.paraMeta[i].unit}); + arguments.emplace_back(m_P[i], m_nodeMeta.paraMeta[i].unit); // m_n_samples is not part of the meta data (impossible due to size_t vs. double...). // Therefore it has to be added separately - arguments.push_back({(int)m_n_samples, ""}); + arguments.emplace_back((int)m_n_samples, ""); return className() + "(" + Py::Fmt::printArguments(arguments) + ")"; } diff --git a/Sample/StandardSamples/FeNiBilayerBuilder.cpp b/Sample/StandardSamples/FeNiBilayerBuilder.cpp index 5516163bfc7..cb0a618ec67 100644 --- a/Sample/StandardSamples/FeNiBilayerBuilder.cpp +++ b/Sample/StandardSamples/FeNiBilayerBuilder.cpp @@ -89,7 +89,7 @@ public: //! @ingroup standard_samples class FeNiBilayer { public: - FeNiBilayer(Options opt = {}) + explicit FeNiBilayer(Options opt = {}) : NBilayers(opt.m_NBilayers) , angle(opt.m_angle) , magnetizationMagnitude(opt.m_magnetizationMagnitude) diff --git a/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.cpp b/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.cpp index ae0cf5b9c6f..247e45c8506 100644 --- a/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.cpp +++ b/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.cpp @@ -18,7 +18,7 @@ MultiLayer* ExemplarySamples::createMultiLayerWithNCRoughness() { - auto sample = createMultiLayerWithRoughness(); + auto* sample = createMultiLayerWithRoughness(); sample->setRoughnessModel(RoughnessModel::NEVOT_CROCE); return sample; } diff --git a/Tests/Unit/Base/FileSystemUtilsTest.cpp b/Tests/Unit/Base/FileSystemUtilsTest.cpp index c27423f5c6d..b5cec8bf1ab 100644 --- a/Tests/Unit/Base/FileSystemUtilsTest.cpp +++ b/Tests/Unit/Base/FileSystemUtilsTest.cpp @@ -93,7 +93,7 @@ TEST_F(FileSystemUtilsTest, stem) EXPECT_EQ(BaseUtils::Filesystem::stem("/home/james/filename.txt.gz"), "filename.txt"); } -TEST_F(FileSystemUtilsTest, stem_ext) +TEST_F(FileSystemUtilsTest, StemAndExtension) { EXPECT_EQ(BaseUtils::Filesystem::stem_ext(""), ""); EXPECT_EQ(BaseUtils::Filesystem::stem_ext("/home/james/"), ""); diff --git a/Tests/Unit/Param/DistributionHandlerTest.cpp b/Tests/Unit/Param/DistributionHandlerTest.cpp index e906c97fd43..e38b2dc294d 100644 --- a/Tests/Unit/Param/DistributionHandlerTest.cpp +++ b/Tests/Unit/Param/DistributionHandlerTest.cpp @@ -5,8 +5,7 @@ class DistributionHandlerTest : public ::testing::Test { protected: - DistributionHandlerTest() : m_value(99.0) {} - double m_value; + DistributionHandlerTest() {} }; TEST_F(DistributionHandlerTest, DistributionHandlerConstructor) diff --git a/Tests/Unit/Param/INodeTest.cpp b/Tests/Unit/Param/INodeTest.cpp index a7238a4f4d8..136574ff367 100644 --- a/Tests/Unit/Param/INodeTest.cpp +++ b/Tests/Unit/Param/INodeTest.cpp @@ -19,11 +19,12 @@ public: TestClass() = default; - virtual ~TestClass() + ~TestClass() { for (auto* child : m_nodes) delete child; - } + } override; + void accept(INodeVisitor* visitor) const override { visitor->visit(this); } void appendChild(INode* node) { m_nodes.push_back(node); } diff --git a/Tests/Unit/Param/RangedDistributionTest.cpp b/Tests/Unit/Param/RangedDistributionTest.cpp index 85cc8058373..481bf4a831e 100644 --- a/Tests/Unit/Param/RangedDistributionTest.cpp +++ b/Tests/Unit/Param/RangedDistributionTest.cpp @@ -70,7 +70,7 @@ template <class T> void RangedDistributionTest::checkStandardSampling() template <class T> void RangedDistributionTest::checkZeroWidth() { - T distr(/*n_samples = */ 10, /*hwhm_factor = */ 3.0); + T distr(10, 3.0); const std::vector<ParameterSample>& samples = distr.generateSamples(1.0, 0.0); EXPECT_EQ(distr.nSamples(), samples.size()); -- GitLab