From c35579227bf2ca0f00cf7c9aedb4da2adcb89de2 Mon Sep 17 00:00:00 2001 From: Uwe Date: Mon, 18 Jul 2022 02:52:48 +0200 Subject: [PATCH] [Path] remove superfluous nullptr checks --- src/Mod/Path/App/Voronoi.cpp | 2 +- src/Mod/Path/App/VoronoiCell.cpp | 2 +- src/Mod/Path/App/VoronoiEdge.cpp | 2 +- src/Mod/Path/App/VoronoiPyImp.cpp | 2 +- src/Mod/Path/App/VoronoiVertex.cpp | 2 +- src/Mod/Path/Gui/ViewProviderPath.cpp | 2 +- src/Mod/Path/PathSimulator/App/PathSim.cpp | 6 +++--- src/Mod/Path/PathSimulator/App/PathSimPyImp.cpp | 2 +- src/Mod/Path/PathSimulator/App/VolSim.h | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Mod/Path/App/Voronoi.cpp b/src/Mod/Path/App/Voronoi.cpp index e5c9f116db..7dcb1fd5c2 100644 --- a/src/Mod/Path/App/Voronoi.cpp +++ b/src/Mod/Path/App/Voronoi.cpp @@ -192,7 +192,7 @@ void Voronoi::colorExterior(const Voronoi::diagram_type::edge_type *edge, std::s edge->color(colorValue); edge->twin()->color(colorValue); auto v = edge->vertex1(); - if (v == nullptr || !edge->is_primary()) { + if (!v || !edge->is_primary()) { return; } v->color(colorValue); diff --git a/src/Mod/Path/App/VoronoiCell.cpp b/src/Mod/Path/App/VoronoiCell.cpp index 460bd612a9..36dfeac720 100644 --- a/src/Mod/Path/App/VoronoiCell.cpp +++ b/src/Mod/Path/App/VoronoiCell.cpp @@ -55,7 +55,7 @@ VoronoiCell::~VoronoiCell() { } bool VoronoiCell::isBound(void) const { - if (ptr != nullptr && dia.isValid() && index != Voronoi::InvalidIndex) { + if (ptr && dia.isValid() && index != Voronoi::InvalidIndex) { if (&(dia->cells()[index]) == ptr) { return true; } diff --git a/src/Mod/Path/App/VoronoiEdge.cpp b/src/Mod/Path/App/VoronoiEdge.cpp index 6d825c0706..c88520be47 100644 --- a/src/Mod/Path/App/VoronoiEdge.cpp +++ b/src/Mod/Path/App/VoronoiEdge.cpp @@ -56,7 +56,7 @@ VoronoiEdge::~VoronoiEdge() { } bool VoronoiEdge::isBound(void) const { - if (ptr != nullptr && dia.isValid() && index != Voronoi::InvalidIndex) { + if (ptr && dia.isValid() && index != Voronoi::InvalidIndex) { if (&(dia->edges()[index]) == ptr) { return true; } diff --git a/src/Mod/Path/App/VoronoiPyImp.cpp b/src/Mod/Path/App/VoronoiPyImp.cpp index c3a92cee59..3fe28778c4 100644 --- a/src/Mod/Path/App/VoronoiPyImp.cpp +++ b/src/Mod/Path/App/VoronoiPyImp.cpp @@ -188,7 +188,7 @@ static bool callbackWithVertex(Voronoi::diagram_type *dia, PyObject *callback, c #endif Py_DECREF(arglist); Py_DECREF(vx); - if (result == nullptr) { + if (!result) { bail = true; } else { rc = result == Py_True; diff --git a/src/Mod/Path/App/VoronoiVertex.cpp b/src/Mod/Path/App/VoronoiVertex.cpp index 64379fe99b..94c384ce48 100644 --- a/src/Mod/Path/App/VoronoiVertex.cpp +++ b/src/Mod/Path/App/VoronoiVertex.cpp @@ -56,7 +56,7 @@ VoronoiVertex::~VoronoiVertex() { } bool VoronoiVertex::isBound(void) const { - if (ptr != nullptr && dia.isValid() && index != Voronoi::InvalidIndex) { + if (ptr && dia.isValid() && index != Voronoi::InvalidIndex) { if (&(dia->vertices()[index]) == ptr) { return true; } diff --git a/src/Mod/Path/Gui/ViewProviderPath.cpp b/src/Mod/Path/Gui/ViewProviderPath.cpp index dbb449b4d1..570d0106b9 100644 --- a/src/Mod/Path/Gui/ViewProviderPath.cpp +++ b/src/Mod/Path/Gui/ViewProviderPath.cpp @@ -588,7 +588,7 @@ private: colorindex.push_back(color); } - if (next != nullptr) { + if (next) { points.push_back(*next); markers.push_back(*next); colorindex.push_back(color); diff --git a/src/Mod/Path/PathSimulator/App/PathSim.cpp b/src/Mod/Path/PathSimulator/App/PathSim.cpp index 5feb2c849a..c3e66e7af8 100644 --- a/src/Mod/Path/PathSimulator/App/PathSim.cpp +++ b/src/Mod/Path/PathSimulator/App/PathSim.cpp @@ -46,9 +46,9 @@ PathSim::PathSim() PathSim::~PathSim() { - if (m_stock != nullptr) + if (m_stock) delete m_stock; - if (m_tool != nullptr) + if (m_tool) delete m_tool; } @@ -68,7 +68,7 @@ Base::Placement * PathSim::ApplyCommand(Base::Placement * pos, Command * cmd) Point3D fromPos(*pos); Point3D toPos(*pos); toPos.UpdateCmd(*cmd); - if (m_tool != nullptr) + if (m_tool) { if (cmd->Name == "G0" || cmd->Name == "G1") { diff --git a/src/Mod/Path/PathSimulator/App/PathSimPyImp.cpp b/src/Mod/Path/PathSimulator/App/PathSimPyImp.cpp index d657a9fb17..d8ea0514dd 100644 --- a/src/Mod/Path/PathSimulator/App/PathSimPyImp.cpp +++ b/src/Mod/Path/PathSimulator/App/PathSimPyImp.cpp @@ -87,7 +87,7 @@ PyObject* PathSimPy::GetResultMesh(PyObject * args) if (!PyArg_ParseTuple(args, "")) return nullptr; cStock *stock = getPathSimPtr()->m_stock; - if (stock == nullptr) + if (!stock) { PyErr_SetString(PyExc_RuntimeError, "Simulation has stock object"); return nullptr; diff --git a/src/Mod/Path/PathSimulator/App/VolSim.h b/src/Mod/Path/PathSimulator/App/VolSim.h index fbf37ee59f..c14a91c35e 100644 --- a/src/Mod/Path/PathSimulator/App/VolSim.h +++ b/src/Mod/Path/PathSimulator/App/VolSim.h @@ -119,7 +119,7 @@ public: ~Array2D() { - if (data != nullptr) + if (data) delete[] data; }