diff --git a/src/libslic3r/ExPolygon.hpp b/src/libslic3r/ExPolygon.hpp index 6f38846736..c0dcac1054 100644 --- a/src/libslic3r/ExPolygon.hpp +++ b/src/libslic3r/ExPolygon.hpp @@ -169,10 +169,10 @@ inline Polylines to_polylines(ExPolygon &&src) Polyline &pl = polylines[idx ++]; pl.points = std::move(src.contour.points); pl.points.push_back(pl.points.front()); - for (Polygons::const_iterator ith = src.holes.begin(); ith != src.holes.end(); ++ith) { + for (auto ith = src.holes.begin(); ith != src.holes.end(); ++ith) { Polyline &pl = polylines[idx ++]; pl.points = std::move(ith->points); - pl.points.push_back(ith->points.front()); + pl.points.push_back(p1.points.front()); } assert(idx == polylines.size()); return polylines; @@ -183,14 +183,14 @@ inline Polylines to_polylines(ExPolygons &&src) Polylines polylines; polylines.assign(number_polygons(src), Polyline()); size_t idx = 0; - for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++it) { + for (auto it = src.begin(); it != src.end(); ++it) { Polyline &pl = polylines[idx ++]; pl.points = std::move(it->contour.points); pl.points.push_back(pl.points.front()); - for (Polygons::const_iterator ith = it->holes.begin(); ith != it->holes.end(); ++ith) { + for (auto ith = it->holes.begin(); ith != it->holes.end(); ++ith) { Polyline &pl = polylines[idx ++]; pl.points = std::move(ith->points); - pl.points.push_back(ith->points.front()); + pl.points.push_back(pl.points.front()); } } assert(idx == polylines.size()); diff --git a/src/libslic3r/ExtrusionEntity.hpp b/src/libslic3r/ExtrusionEntity.hpp index 1c990f5eaf..5e6a51d20a 100644 --- a/src/libslic3r/ExtrusionEntity.hpp +++ b/src/libslic3r/ExtrusionEntity.hpp @@ -242,7 +242,7 @@ public: ExtrusionLoop(ExtrusionPaths &&paths, ExtrusionLoopRole role = elrDefault) : paths(std::move(paths)), m_loop_role(role) {} ExtrusionLoop(const ExtrusionPath &path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role) { this->paths.push_back(path); } - ExtrusionLoop(const ExtrusionPath &&path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role) + ExtrusionLoop(ExtrusionPath &&path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role) { this->paths.emplace_back(std::move(path)); } bool is_loop() const override{ return true; } bool can_reverse() const override { return false; } diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index 7a1cf206ea..14d063155b 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -817,7 +817,7 @@ private: this->set_material_id(other.material_id()); } // Providing a new mesh, therefore this volume will get a new unique ID assigned. - ModelVolume(ModelObject *object, const ModelVolume &other, const TriangleMesh &&mesh) : + ModelVolume(ModelObject *object, const ModelVolume &other, TriangleMesh &&mesh) : name(other.name), source(other.source), m_mesh(new TriangleMesh(std::move(mesh))), config(other.config), m_type(other.m_type), object(object), m_transformation(other.m_transformation) { assert(this->id().valid()); diff --git a/src/libslic3r/Polygon.hpp b/src/libslic3r/Polygon.hpp index d245403392..0898205655 100644 --- a/src/libslic3r/Polygon.hpp +++ b/src/libslic3r/Polygon.hpp @@ -220,10 +220,10 @@ inline Polylines to_polylines(Polygons &&polys) Polylines polylines; polylines.assign(polys.size(), Polyline()); size_t idx = 0; - for (Polygons::const_iterator it = polys.begin(); it != polys.end(); ++ it) { + for (auto it = polys.begin(); it != polys.end(); ++ it) { Polyline &pl = polylines[idx ++]; pl.points = std::move(it->points); - pl.points.push_back(it->points.front()); + pl.points.push_back(pl.points.front()); } assert(idx == polylines.size()); return polylines; @@ -242,7 +242,7 @@ inline Polygons to_polygons(std::vector &&paths) { Polygons out; out.reserve(paths.size()); - for (const Points &path : paths) + for (Points &path : paths) out.emplace_back(std::move(path)); return out; } diff --git a/src/libslic3r/Polyline.hpp b/src/libslic3r/Polyline.hpp index 5766d9671b..256dca28cc 100644 --- a/src/libslic3r/Polyline.hpp +++ b/src/libslic3r/Polyline.hpp @@ -139,7 +139,7 @@ inline Polylines to_polylines(std::vector &&paths) { Polylines out; out.reserve(paths.size()); - for (const Points &path : paths) + for (Points &path : paths) out.emplace_back(std::move(path)); return out; } diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 85246df315..c521393dff 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -885,9 +885,9 @@ std::string Print::export_gcode(const std::string& path_template, GCodeProcessor message = L("Generating G-code"); this->set_status(90, message); - // The following line may die for multiple reasons. - GCode gcode; - gcode.do_export(this, path.c_str(), result, thumbnail_cb); + // Create GCode on heap, it has quite a lot of data. + std::unique_ptr gcode(new GCode); + gcode->do_export(this, path.c_str(), result, thumbnail_cb); return path.c_str(); } diff --git a/src/libslic3r/Surface.hpp b/src/libslic3r/Surface.hpp index 4920efbbfd..ef1de30e95 100644 --- a/src/libslic3r/Surface.hpp +++ b/src/libslic3r/Surface.hpp @@ -58,11 +58,11 @@ public: thickness(rhs.thickness), thickness_layers(rhs.thickness_layers), bridge_angle(rhs.bridge_angle), extra_perimeters(rhs.extra_perimeters) {}; - Surface(SurfaceType _surface_type, const ExPolygon &&_expolygon) + Surface(SurfaceType _surface_type, ExPolygon &&_expolygon) : surface_type(_surface_type), expolygon(std::move(_expolygon)), thickness(-1), thickness_layers(1), bridge_angle(-1), extra_perimeters(0) {}; - Surface(const Surface &other, const ExPolygon &&_expolygon) + Surface(const Surface &other, ExPolygon &&_expolygon) : surface_type(other.surface_type), expolygon(std::move(_expolygon)), thickness(other.thickness), thickness_layers(other.thickness_layers), bridge_angle(other.bridge_angle), extra_perimeters(other.extra_perimeters) @@ -159,7 +159,7 @@ inline ExPolygons to_expolygons(Surfaces &&src) { ExPolygons expolygons; expolygons.reserve(src.size()); - for (Surfaces::const_iterator it = src.begin(); it != src.end(); ++it) + for (auto it = src.begin(); it != src.end(); ++it) expolygons.emplace_back(ExPolygon(std::move(it->expolygon))); src.clear(); return expolygons; @@ -260,8 +260,8 @@ inline void surfaces_append(Surfaces &dst, ExPolygons &&src, SurfaceType surface inline void surfaces_append(Surfaces &dst, ExPolygons &&src, const Surface &surfaceTempl) { dst.reserve(dst.size() + number_polygons(src)); - for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++ it) - dst.emplace_back(Surface(surfaceTempl, std::move(*it))); + for (ExPolygon& explg : src) + dst.emplace_back(Surface(surfaceTempl, std::move(explg))); src.clear(); }