diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index 6797cfd170..d5cf751632 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -448,7 +448,7 @@ void Area::addWire(CArea &area, const TopoDS_Wire& wire, AREA_WARN("ccurve not closed"); ccurve.append(ccurve.m_vertices.front()); } - area.append(ccurve); + area.move(std::move(ccurve)); } } diff --git a/src/Mod/Path/libarea/Area.cpp b/src/Mod/Path/libarea/Area.cpp index f30d4f45cd..be6b8e8e98 100644 --- a/src/Mod/Path/libarea/Area.cpp +++ b/src/Mod/Path/libarea/Area.cpp @@ -47,6 +47,11 @@ void CArea::append(const CCurve& curve) m_curves.push_back(curve); } +void CArea::move(CCurve&& curve) +{ + m_curves.push_back(std::move(curve)); +} + void CArea::FitArcs(){ for(std::list::iterator It = m_curves.begin(); It != m_curves.end(); It++) { diff --git a/src/Mod/Path/libarea/Area.h b/src/Mod/Path/libarea/Area.h index 6c0bced98d..3f6eabe756 100644 --- a/src/Mod/Path/libarea/Area.h +++ b/src/Mod/Path/libarea/Area.h @@ -59,6 +59,7 @@ public: static double m_clipper_scale; void append(const CCurve& curve); + void move(CCurve&& curve); void Subtract(const CArea& a2); void Intersect(const CArea& a2); void Union(const CArea& a2); diff --git a/src/Mod/Path/libarea/Curve.cpp b/src/Mod/Path/libarea/Curve.cpp index 0235090688..2eaaefa2f1 100644 --- a/src/Mod/Path/libarea/Curve.cpp +++ b/src/Mod/Path/libarea/Curve.cpp @@ -269,9 +269,9 @@ void CCurve::FitArcs(bool retry) if(arc_added) { - m_vertices.clear(); - for(std::list::iterator It = new_vertices.begin(); It != new_vertices.end(); It++)m_vertices.push_back(*It); - for(std::list::iterator It = might_be_an_arc.begin(); It != might_be_an_arc.end(); It++)m_vertices.push_back(*(*It)); + for(auto *v : might_be_an_arc) + new_vertices.push_back(*v); + m_vertices.swap(new_vertices); } } @@ -466,7 +466,7 @@ void CCurve::Reverse() prev_v = &v; } - m_vertices = new_vertices; + m_vertices.swap(new_vertices); } double CCurve::GetArea()const @@ -556,7 +556,7 @@ void CCurve::ChangeStart(const Point &p) { if(started) { - *this = new_curve; + m_vertices.swap(new_curve.m_vertices); } } @@ -656,7 +656,7 @@ void CCurve::RemoveTinySpans() { new_curve.m_vertices.push_back(vertex); } } - *this = new_curve; + m_vertices.swap(new_curve.m_vertices); } void CCurve::ChangeEnd(const Point &p) { @@ -691,7 +691,7 @@ void CCurve::ChangeEnd(const Point &p) { prev_p = &(vertex.m_p); } - *this = new_curve; + m_vertices.swap(new_curve.m_vertices); } Point CCurve::NearestPoint(const Span& p, double *d)const