From 78e2a12d2d58bce0e069ae2bc7c450162d6c68f9 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Fri, 11 Apr 2025 08:27:23 +0200 Subject: [PATCH 01/10] Sketcher: Fix 463717 Variable copied when it could be moved --- src/Mod/Sketcher/App/SketchObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index eb95bdfab4..f5bf6a558a 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -11072,7 +11072,7 @@ std::vector SketchObject::getElementTypes(bool all) const void SketchObject::setExpression(const App::ObjectIdentifier& path, std::shared_ptr expr) { - DocumentObject::setExpression(path, expr); + DocumentObject::setExpression(path, std::move(expr)); if (noRecomputes) { // if we do not have a recompute, the sketch must be solved to update the DoF of the solver, From 53b9c54f97957a6090921168f3a4806e89bd4e7b Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Fri, 11 Apr 2025 08:28:48 +0200 Subject: [PATCH 02/10] Sketcher: Fix 512831 Variable copied when it could be moved --- src/Mod/Sketcher/App/SketchObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index f5bf6a558a..c291d384f4 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1185,7 +1185,7 @@ void SketchObject::setConstraintExpression(int constNum, const std::string& newE if (info.expression) { try { std::shared_ptr expr(App::Expression::parse(this, newExpression)); - setExpression(path, expr); + setExpression(path, std::move(expr)); } catch (const Base::Exception&) { Base::Console().Error("Failed to set constraint expression."); From 6adebe348e24cb972f1eb4b27c71ac140ee1bb71 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Fri, 11 Apr 2025 08:30:01 +0200 Subject: [PATCH 03/10] Sketcher: Fix 512301 Variable copied when it could be moved --- src/Mod/Sketcher/App/SketchObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index c291d384f4..3329375315 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1142,7 +1142,7 @@ void SketchObject::reverseAngleConstraintToSupplementary(Constraint* constr, int // Edit the expression if any, else modify constraint value directly if (constraintHasExpression(constNum)) { std::string expression = getConstraintExpression(constNum); - setConstraintExpression(constNum, reverseAngleConstraintExpression(expression)); + setConstraintExpression(constNum, std::move(reverseAngleConstraintExpression(expression))); } else { double actAngle = constr->getValue(); From de17a7acee240a9a4039621f9f8d86fbe24f0655 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Fri, 11 Apr 2025 08:31:59 +0200 Subject: [PATCH 04/10] Sketcher: 532658 Use of auto that causes a copy Also fixes 532658 --- src/Mod/Sketcher/App/SketchObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 3329375315..b1ff072ed1 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1935,7 +1935,7 @@ int SketchObject::delGeometriesExclusiveList(const std::vector& GeoIds) void SketchObject::replaceGeometries(std::vector oldGeoIds, std::vector& newGeos) { - auto vals = getInternalGeometry(); + auto& vals = getInternalGeometry(); auto newVals(vals); if (std::any_of(oldGeoIds.begin(), oldGeoIds.end(), [](auto geoId) { From 7f49a4e668e4e6abe18c29c62acb6b9a10093c00 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Fri, 11 Apr 2025 08:35:36 +0200 Subject: [PATCH 05/10] Sketcher: Fix 513105 Variable copied when it could be moved --- src/Mod/Sketcher/App/SketchObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index b1ff072ed1..d4048fe744 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -11589,7 +11589,7 @@ int SketchObject::renameConstraint(int GeoId, std::string name) Base::StateLocker lock(managedoperation, true); Constraint* copy = item->clone(); - copy->Name = name; + copy->Name = std::move(name); Constraints.set1Value(GeoId, copy); delete copy; From be264928fcb45f2406bb8bd1e6eb2116a1271390 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Mon, 14 Apr 2025 08:01:07 +0200 Subject: [PATCH 06/10] Sketcher: Fix 515688, 513858, 515692, Variable copied # Conflicts: # src/Mod/Sketcher/App/SketchObject.cpp --- src/Mod/Sketcher/App/SketchObject.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index d4048fe744..f75414610c 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -2493,7 +2493,7 @@ void SketchObject::transferFilletConstraints(int geoId1, PointPos posId1, int ge } } } - delConstraints(deleteme, false); + delConstraints(std::move(deleteme), false); return; } @@ -3449,7 +3449,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point) addConstraint(std::move(newConstr)); }; - delConstraints(idsOfOldConstraints, false); + delConstraints(std::move(idsOfOldConstraints), false); if (!isOriginalCurvePeriodic) { transferConstraints(GeoId, PointPos::start, newIds.front(), PointPos::start, true); @@ -3808,7 +3808,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) solve(); } - delConstraints(idsOfOldConstraints); + delConstraints(std::move(idsOfOldConstraints)); addConstraints(newConstraints); for (auto& cons : newConstraints) { From 70d11e33dc13ac0517ad86f9f8da684b9711630e Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Mon, 14 Apr 2025 08:01:07 +0200 Subject: [PATCH 07/10] Sketcher: Fix 529853 Variable copied when it could be moved --- src/Mod/Sketcher/App/SketchObject.cpp | 2 +- src/Mod/Sketcher/App/SketchObject.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index f75414610c..a678ee15e7 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1353,7 +1353,7 @@ int SketchObject::diagnoseAdditionalConstraints( return lastDoF; } -int SketchObject::moveGeometries(std::vector geoEltIds, const Base::Vector3d& toPoint, bool relative, +int SketchObject::moveGeometries(const std::vector& geoEltIds, const Base::Vector3d& toPoint, bool relative, bool updateGeoBeforeMoving) { diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index 4d17218403..2b486aaed1 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -354,7 +354,7 @@ public: /// toggle the driving status of this constraint int toggleVirtualSpace(int ConstrId); /// move this point to a new location and solve - int moveGeometries(std::vector geoEltIds, + int moveGeometries(const std::vector& geoEltIds, const Base::Vector3d& toPoint, bool relative = false, bool updateGeoBeforeMoving = false); From 6b87d7df22eca0346935efa3cffc4d8b0adbc18e Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Fri, 11 Apr 2025 08:45:09 +0200 Subject: [PATCH 08/10] Sketcher: Fix 512328 Use of auto that causes a copy --- src/Mod/Sketcher/App/SketchObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index a678ee15e7..c0670b4056 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -426,7 +426,7 @@ const std::map SketchObject::getInternalElementMap() co if (!internalElementMap.empty() || !MakeInternals.getValue()) return internalElementMap; - auto internalShape = InternalShape.getShape(); + const auto& internalShape = InternalShape.getShape(); auto shape = Shape.getShape().located(TopLoc_Location()); if (!internalShape.isNull() && !shape.isNull()) { std::vector names; From 47a43e21b24468ce207b828c285d15cde8acec87 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Fri, 11 Apr 2025 09:09:31 +0200 Subject: [PATCH 09/10] =?UTF-8?q?Sketcher:=20Fix=20=C2=B7=20=C2=B7=20?= =?UTF-8?q?=C2=B7=20532547=20Variable=20copied=20when=20it=20could=20be=20?= =?UTF-8?q?moved?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Mod/Sketcher/App/SketchObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index c0670b4056..7c52b0e953 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -9262,7 +9262,7 @@ const std::vector> SketchObject::getCoincidenc std::map tmp; tmp.insert(std::pair(constr->First, constr->FirstPos)); tmp.insert(std::pair(constr->Second, constr->SecondPos)); - coincidenttree.push_back(tmp); + coincidenttree.push_back(std::move(tmp)); } else if (firstpresentin != -1) { // add to existing group From 3f79626799ffa7621dce44539d52fb2040869a56 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Fri, 11 Apr 2025 09:12:16 +0200 Subject: [PATCH 10/10] Sketcher: Fix 513269 Variable copied when it could be moved --- src/Mod/Sketcher/App/SketchObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 7c52b0e953..70d9a72bd4 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -7083,7 +7083,7 @@ int SketchObject::carbonCopy(App::DocumentObject* pObj, bool construction) * * if (expr_info.expression)*/ // App::Expression * expr = parse(this, const std::string& buffer); - setExpression(Constraints.createPath(nextcid), expr); + setExpression(Constraints.createPath(nextcid), std::move(expr)); } } }