From aac2c45450320c8a63825aba0c1e44d46c727a79 Mon Sep 17 00:00:00 2001 From: Mark Hindess Date: Thu, 18 Apr 2013 19:50:05 +0100 Subject: [PATCH] Avoid merging meshes when there is only one mesh to merge. When slicing yoda.stl it reduces peak memory usage by 5% and speeds up slicing by 13%. Further optimization using a simple proxy to implement the two methods (size/extends) needed on the merge meshes is also possible and undoubtedly worthwhile. --- lib/Slic3r/Print.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 634421a2a..70e608750 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -118,7 +118,8 @@ sub add_model { $mesh->scale($Slic3r::Config->scale / &Slic3r::SCALING_FACTOR); } - my $complete_mesh = Slic3r::TriangleMesh->merge(grep defined $_, @meshes); + my @defined_meshes = grep defined $_, @meshes; + my $complete_mesh = @defined_meshes == 1 ? $defined_meshes[0] : Slic3r::TriangleMesh->merge(@defined_meshes); # initialize print object my $print_object = Slic3r::Print::Object->new(