From 85ad56b43bedf882097255e643b8ab974943f7b0 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 6 Dec 2022 12:18:05 +0100 Subject: [PATCH] Optimization: std::vector can be quite slow to access --- src/libslic3r/TriangleMesh.cpp | 2 +- src/libslic3r/TriangleMesh.hpp | 2 +- src/libslic3r/TriangleMeshSlicer.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/TriangleMesh.cpp b/src/libslic3r/TriangleMesh.cpp index 6e17daa56..d5fe83c26 100644 --- a/src/libslic3r/TriangleMesh.cpp +++ b/src/libslic3r/TriangleMesh.cpp @@ -622,7 +622,7 @@ std::vector its_face_edge_ids(const indexed_triangle_set &its, std::funct return its_face_edge_ids_impl(its, [](const uint32_t){ return true; }, throw_on_cancel_callback); } -std::vector its_face_edge_ids(const indexed_triangle_set &its, const std::vector &face_mask) +std::vector its_face_edge_ids(const indexed_triangle_set &its, const std::vector &face_mask) { return its_face_edge_ids_impl(its, [&face_mask](const uint32_t idx){ return face_mask[idx]; }, [](){}); } diff --git a/src/libslic3r/TriangleMesh.hpp b/src/libslic3r/TriangleMesh.hpp index d8096eae2..26701bdf5 100644 --- a/src/libslic3r/TriangleMesh.hpp +++ b/src/libslic3r/TriangleMesh.hpp @@ -188,7 +188,7 @@ private: // Used for chaining slice lines into polygons. std::vector its_face_edge_ids(const indexed_triangle_set &its); std::vector its_face_edge_ids(const indexed_triangle_set &its, std::function throw_on_cancel_callback); -std::vector its_face_edge_ids(const indexed_triangle_set &its, const std::vector &face_mask); +std::vector its_face_edge_ids(const indexed_triangle_set &its, const std::vector &face_mask); // Having the face neighbors available, assign unique edge IDs to face edges for chaining of polygons over slices. std::vector its_face_edge_ids(const indexed_triangle_set &its, std::vector &face_neighbors, bool assign_unbound_edges = false, int *num_edges = nullptr); diff --git a/src/libslic3r/TriangleMeshSlicer.cpp b/src/libslic3r/TriangleMeshSlicer.cpp index 63802961b..461d8c22e 100644 --- a/src/libslic3r/TriangleMeshSlicer.cpp +++ b/src/libslic3r/TriangleMeshSlicer.cpp @@ -1805,7 +1805,7 @@ Polygons slice_mesh( { bool trafo_identity = is_identity(params.trafo); Transform3f tf; - std::vector face_mask(mesh.indices.size(), false); + std::vector face_mask(mesh.indices.size(), 0); { // 1) Mark vertices as below or above the slicing plane.