From f7dec6b60198a4b921784fa8079ac5319fd74bdc Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Wed, 22 Dec 2021 18:51:45 +0100 Subject: [PATCH] Part: Geometry and Sketcher: GeometryFacade and ExternalGeometryFacade ====================================================================== Change pass-by-value to const reference. Thanks Kunda! https://lgtm.com/projects/g/FreeCAD/FreeCAD/alerts/?mode=tree&ruleFocus=2163210742 https://forum.freecadweb.org/viewtopic.php?p=555658#p555658 --- src/Mod/Part/App/Geometry.cpp | 8 ++++---- src/Mod/Part/App/Geometry.h | 8 ++++---- src/Mod/Sketcher/App/ExternalGeometryFacade.h | 18 +++++++++--------- src/Mod/Sketcher/App/GeometryFacade.h | 16 ++++++++-------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Mod/Part/App/Geometry.cpp b/src/Mod/Part/App/Geometry.cpp index fdcc29a688..6096e4a2eb 100644 --- a/src/Mod/Part/App/Geometry.cpp +++ b/src/Mod/Part/App/Geometry.cpp @@ -298,7 +298,7 @@ bool Geometry::hasExtension(Base::Type type) const return false; } -bool Geometry::hasExtension(std::string name) const +bool Geometry::hasExtension(const std::string & name) const { for( auto ext : extensions) { if(ext->getName() == name) @@ -318,7 +318,7 @@ std::weak_ptr Geometry::getExtension(Base::Type type) throw Base::ValueError("No geometry extension of the requested type."); } -std::weak_ptr Geometry::getExtension(std::string name) +std::weak_ptr Geometry::getExtension(const std::string & name) { for( auto ext : extensions) { if(ext->getName() == name) @@ -333,7 +333,7 @@ std::weak_ptr Geometry::getExtension(Base::Type type) c return const_cast(this)->getExtension(type).lock(); } -std::weak_ptr Geometry::getExtension(std::string name) const +std::weak_ptr Geometry::getExtension(const std::string & name) const { return const_cast(this)->getExtension(name).lock(); } @@ -371,7 +371,7 @@ void Geometry::deleteExtension(Base::Type type) extensions.end()); } -void Geometry::deleteExtension(std::string name) +void Geometry::deleteExtension(const std::string & name) { extensions.erase( std::remove_if( extensions.begin(), diff --git a/src/Mod/Part/App/Geometry.h b/src/Mod/Part/App/Geometry.h index 467f6b8a5d..2a3c09a316 100644 --- a/src/Mod/Part/App/Geometry.h +++ b/src/Mod/Part/App/Geometry.h @@ -99,14 +99,14 @@ public: std::vector> getExtensions() const; bool hasExtension(Base::Type type) const; - bool hasExtension(std::string name) const; + bool hasExtension(const std::string & name) const; std::weak_ptr getExtension(Base::Type type) const; - std::weak_ptr getExtension(std::string name) const; + std::weak_ptr getExtension(const std::string & name) const; std::weak_ptr getExtension(Base::Type type); - std::weak_ptr getExtension(std::string name); + std::weak_ptr getExtension(const std::string & name); void setExtension(std::unique_ptr &&geo); void deleteExtension(Base::Type type); - void deleteExtension(std::string name); + void deleteExtension(const std::string & name); void mirror(const Base::Vector3d& point); void mirror(const Base::Vector3d& point, const Base::Vector3d& dir); diff --git a/src/Mod/Sketcher/App/ExternalGeometryFacade.h b/src/Mod/Sketcher/App/ExternalGeometryFacade.h index bbec6668f7..8db4252fa3 100644 --- a/src/Mod/Sketcher/App/ExternalGeometryFacade.h +++ b/src/Mod/Sketcher/App/ExternalGeometryFacade.h @@ -131,19 +131,19 @@ public: std::vector> getExtensions() const {return getGeo()->getExtensions();}; bool hasExtension(Base::Type type) const {return getGeo()->hasExtension(type);}; - bool hasExtension(std::string name) const {return getGeo()->hasExtension(name);}; + bool hasExtension(const std::string & name) const {return getGeo()->hasExtension(name);}; std::weak_ptr getExtension(Base::Type type) const {return getGeo()->getExtension(type);}; - std::weak_ptr getExtension(std::string name) const {return getGeo()->getExtension(name);}; + std::weak_ptr getExtension(const std::string & name) const {return getGeo()->getExtension(name);}; void setExtension(std::unique_ptr &&geo) {return getGeo()->setExtension(std::move(geo));}; void deleteExtension(Base::Type type) {return getGeo()->deleteExtension(type);}; - void deleteExtension(std::string name) {return getGeo()->deleteExtension(name);}; + void deleteExtension(const std::string & name) {return getGeo()->deleteExtension(name);}; - void mirror(Base::Vector3d point) {return getGeo()->mirror(point);}; - void mirror(Base::Vector3d point, Base::Vector3d dir) {return getGeo()->mirror(point, dir);}; - void rotate(Base::Placement plm) {return getGeo()->rotate(plm);}; - void scale(Base::Vector3d vec, double scale) {return getGeo()->scale(vec, scale);}; - void transform(Base::Matrix4D mat) {return getGeo()->transform(mat);}; - void translate(Base::Vector3d vec) {return getGeo()->translate(vec);}; + void mirror(const Base::Vector3d & point) {return getGeo()->mirror(point);}; + void mirror(const Base::Vector3d & point, Base::Vector3d dir) {return getGeo()->mirror(point, dir);}; + void rotate(const Base::Placement & plm) {return getGeo()->rotate(plm);}; + void scale(const Base::Vector3d & vec, double scale) {return getGeo()->scale(vec, scale);}; + void transform(const Base::Matrix4D & mat) {return getGeo()->transform(mat);}; + void translate(const Base::Vector3d & vec) {return getGeo()->translate(vec);}; private: void initExtensions(void); diff --git a/src/Mod/Sketcher/App/GeometryFacade.h b/src/Mod/Sketcher/App/GeometryFacade.h index 5c7301a7c3..abe021e343 100644 --- a/src/Mod/Sketcher/App/GeometryFacade.h +++ b/src/Mod/Sketcher/App/GeometryFacade.h @@ -189,19 +189,19 @@ public: std::vector> getExtensions() const {return getGeo()->getExtensions();} bool hasExtension(Base::Type type) const {return getGeo()->hasExtension(type);} - bool hasExtension(std::string name) const {return getGeo()->hasExtension(name);} + bool hasExtension(const std::string & name) const {return getGeo()->hasExtension(name);} std::weak_ptr getExtension(Base::Type type) const {return getGeo()->getExtension(type);} std::weak_ptr getExtension(std::string name) const {return getGeo()->getExtension(name);} void setExtension(std::unique_ptr &&geo) {return getGeo()->setExtension(std::move(geo));} void deleteExtension(Base::Type type) {return getGeo()->deleteExtension(type);} - void deleteExtension(std::string name) {return getGeo()->deleteExtension(name);} + void deleteExtension(const std::string & name) {return getGeo()->deleteExtension(name);} - void mirror(Base::Vector3d point) {return getGeo()->mirror(point);} - void mirror(Base::Vector3d point, Base::Vector3d dir) {return getGeo()->mirror(point, dir);} - void rotate(Base::Placement plm) {return getGeo()->rotate(plm);} - void scale(Base::Vector3d vec, double scale) {return getGeo()->scale(vec, scale);} - void transform(Base::Matrix4D mat) {return getGeo()->transform(mat);} - void translate(Base::Vector3d vec) {return getGeo()->translate(vec);} + void mirror(const Base::Vector3d & point) {return getGeo()->mirror(point);} + void mirror(const Base::Vector3d & point, Base::Vector3d dir) {return getGeo()->mirror(point, dir);} + void rotate(const Base::Placement & plm) {return getGeo()->rotate(plm);} + void scale(const Base::Vector3d & vec, double scale) {return getGeo()->scale(vec, scale);} + void transform(const Base::Matrix4D & mat) {return getGeo()->transform(mat);} + void translate(const Base::Vector3d & vec) {return getGeo()->translate(vec);} // convenience GeometryFunctions bool isGeoType(const Base::Type &type) const { return getGeo()->getTypeId() == type;}