Optimization: std::vector<bool> can be quite slow to access

This commit is contained in:
Lukas Matena 2022-12-06 12:18:05 +01:00
parent fe3a15942b
commit 85ad56b43b
3 changed files with 3 additions and 3 deletions

View file

@ -622,7 +622,7 @@ std::vector<Vec3i> 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); return its_face_edge_ids_impl(its, [](const uint32_t){ return true; }, throw_on_cancel_callback);
} }
std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its, const std::vector<bool> &face_mask) std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its, const std::vector<char> &face_mask)
{ {
return its_face_edge_ids_impl(its, [&face_mask](const uint32_t idx){ return face_mask[idx]; }, [](){}); return its_face_edge_ids_impl(its, [&face_mask](const uint32_t idx){ return face_mask[idx]; }, [](){});
} }

View file

@ -188,7 +188,7 @@ private:
// Used for chaining slice lines into polygons. // Used for chaining slice lines into polygons.
std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its); std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its);
std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its, std::function<void()> throw_on_cancel_callback); std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its, std::function<void()> throw_on_cancel_callback);
std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its, const std::vector<bool> &face_mask); std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its, const std::vector<char> &face_mask);
// Having the face neighbors available, assign unique edge IDs to face edges for chaining of polygons over slices. // Having the face neighbors available, assign unique edge IDs to face edges for chaining of polygons over slices.
std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its, std::vector<Vec3i> &face_neighbors, bool assign_unbound_edges = false, int *num_edges = nullptr); std::vector<Vec3i> its_face_edge_ids(const indexed_triangle_set &its, std::vector<Vec3i> &face_neighbors, bool assign_unbound_edges = false, int *num_edges = nullptr);

View file

@ -1805,7 +1805,7 @@ Polygons slice_mesh(
{ {
bool trafo_identity = is_identity(params.trafo); bool trafo_identity = is_identity(params.trafo);
Transform3f tf; Transform3f tf;
std::vector<bool> face_mask(mesh.indices.size(), false); std::vector<char> face_mask(mesh.indices.size(), 0);
{ {
// 1) Mark vertices as below or above the slicing plane. // 1) Mark vertices as below or above the slicing plane.