Commit: cfa167d57fd607a0adff5efd16c9cc0da5e5a2e4 Author: Ankit Meel Date: Sun Jun 28 14:14:19 2020 +0530 Branches: soc-2020-io-performance https://developer.blender.org/rBcfa167d57fd607a0adff5efd16c9cc0da5e5a2e4
Use Span<T> instead of const Vector<T> & Reasons to prefer `Span`: > - It is shorter. > - It is const by default (whereas you could easily forget the const in > `const Vector<T> &`). And I did forget the `const` here! https://developer.blender.org/D7987#inline-64852 =================================================================== M source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc M source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.hh =================================================================== diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc b/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc index a40e7025b52..7746d427454 100644 --- a/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc +++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc @@ -33,9 +33,9 @@ namespace io { namespace obj { /** Write one line of polygon indices as f v1/vt1/vn1 v2/vt2/vn2 .... */ -void OBJWriter::write_vert_uv_normal_indices(Vector<uint> &vert_indices, - Vector<uint> &uv_indices, - Vector<uint> &normal_indices, +void OBJWriter::write_vert_uv_normal_indices(Span<uint> vert_indices, + Span<uint> uv_indices, + Span<uint> normal_indices, const MPoly &poly_to_write) { fprintf(_outfile, "f "); @@ -50,8 +50,8 @@ void OBJWriter::write_vert_uv_normal_indices(Vector<uint> &vert_indices, } /** Write one line of polygon indices as f v1//vn1 v2//vn2 .... */ -void OBJWriter::write_vert_normal_indices(Vector<uint> &vert_indices, - Vector<uint> &normal_indices, +void OBJWriter::write_vert_normal_indices(Span<uint> vert_indices, + Span<uint> normal_indices, const MPoly &poly_to_write) { fprintf(_outfile, "f "); @@ -65,8 +65,8 @@ void OBJWriter::write_vert_normal_indices(Vector<uint> &vert_indices, } /** Write one line of polygon indices as f v1/vt1 v2/vt2 .... */ -void OBJWriter::write_vert_uv_indices(Vector<uint> &vert_indices, - Vector<uint> &uv_indices, +void OBJWriter::write_vert_uv_indices(Span<uint> vert_indices, + Span<uint> uv_indices, const MPoly &poly_to_write) { fprintf(_outfile, "f "); @@ -80,7 +80,7 @@ void OBJWriter::write_vert_uv_indices(Vector<uint> &vert_indices, } /** Write one line of polygon indices as f v1 v2 .... */ -void OBJWriter::write_vert_indices(Vector<uint> &vert_indices, const MPoly &poly_to_write) +void OBJWriter::write_vert_indices(Span<uint> vert_indices, const MPoly &poly_to_write) { fprintf(_outfile, "f "); for (int j = 0; j < poly_to_write.totloop; j++) { @@ -180,7 +180,7 @@ void OBJWriter::write_usemtl(OBJMesh &obj_mesh_data) * and face normal indices. * \note UV indices are stored while writing UV vertices. */ -void OBJWriter::write_poly_indices(OBJMesh &obj_mesh_data, Vector<Vector<uint>> &uv_indices) +void OBJWriter::write_poly_indices(OBJMesh &obj_mesh_data, Span<Vector<uint>> uv_indices) { Vector<uint> vertex_indices; Vector<uint> normal_indices; diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.hh b/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.hh index f12fac0fddb..26dc1ea2790 100644 --- a/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.hh +++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.hh @@ -78,7 +78,7 @@ class OBJWriter { /** Define and write a face with at least vertex indices, and conditionally with UV vertex * indices and face normal indices. \note UV indices are stored while writing UV vertices. */ - void write_poly_indices(OBJMesh &obj_mesh_data, Vector<Vector<uint>> &uv_indices); + void write_poly_indices(OBJMesh &obj_mesh_data, Span<Vector<uint>> uv_indices); /** Define and write an edge of a curve converted to mesh or a primitive circle as l v1 v2 */ void write_curve_edges(OBJMesh &obj_mesh_data); @@ -95,19 +95,19 @@ class OBJWriter { uint _index_offset[3] = {0, 0, 0}; /** Write one line of polygon indices as f v1 v2 .... */ - void write_vert_indices(Vector<uint> &vert_indices, const MPoly &poly_to_write); + void write_vert_indices(Span<uint> vert_indices, const MPoly &poly_to_write); /** Write one line of polygon indices as f v1//vn1 v2//vn2 .... */ - void write_vert_normal_indices(Vector<uint> &vert_indices, - Vector<uint> &normal_indices, + void write_vert_normal_indices(Span<uint> vert_indices, + Span<uint> normal_indices, const MPoly &poly_to_write); /** Write one line of polygon indices as f v1/vt1 v2/vt2 .... */ - void write_vert_uv_indices(Vector<uint> &vert_indices, - Vector<uint> &uv_indices, + void write_vert_uv_indices(Span<uint> vert_indices, + Span<uint> uv_indices, const MPoly &poly_to_write); /** Write one line of polygon indices as f v1/vt1/vn1 v2/vt2/vn2 .... */ - void write_vert_uv_normal_indices(Vector<uint> &vert_indices, - Vector<uint> &uv_indices, - Vector<uint> &normal_indices, + void write_vert_uv_normal_indices(Span<uint> vert_indices, + Span<uint> uv_indices, + Span<uint> normal_indices, const MPoly &poly_to_write); }; _______________________________________________ Bf-blender-cvs mailing list [email protected] https://lists.blender.org/mailman/listinfo/bf-blender-cvs
