From 7979dd9e9c5fc99648fdb86d9ef4323e9479f468 Mon Sep 17 00:00:00 2001 From: Mark Hindess Date: Mon, 13 May 2013 21:24:49 +0100 Subject: [PATCH] Avoid expensive TriangleMesh BUILD method during clone. Gives 6% speedup and uses less memory when slicing yoda.stl and should give significantly bigger speedup on more complex models and plates. --- lib/Slic3r/TriangleMesh.pm | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/Slic3r/TriangleMesh.pm b/lib/Slic3r/TriangleMesh.pm index 74efc39db..39bfef4c2 100644 --- a/lib/Slic3r/TriangleMesh.pm +++ b/lib/Slic3r/TriangleMesh.pm @@ -3,6 +3,7 @@ use Moo; use Slic3r::Geometry qw(X Y Z A B unscale same_point); use Slic3r::Geometry::Clipper qw(union_ex); +use Storable; # public has 'vertices' => (is => 'ro', required => 1); # id => [$x,$y,$z] @@ -92,11 +93,7 @@ sub merge { } sub clone { - my $self = shift; - return (ref $self)->new( - vertices => [ map [ @$_ ], @{$self->vertices} ], - facets => [ map [ @$_ ], @{$self->facets} ], - ); + Storable::dclone($_[0]) } sub _facet_edges {