Optimization: cache scaled flow width and spacing

This commit is contained in:
Alessandro Ranellucci 2012-09-23 03:03:08 +02:00
parent ec0d3987db
commit bbe0a45b58
9 changed files with 46 additions and 35 deletions

View file

@ -1,13 +1,15 @@
package Slic3r::Flow;
use Moo;
use Slic3r::Geometry qw(PI);
use Slic3r::Geometry qw(PI scale);
has 'nozzle_diameter' => (is => 'ro', required => 1);
has 'layer_height' => (is => 'ro', default => sub { $Slic3r::Config->layer_height });
has 'width' => (is => 'rwp', builder => 1);
has 'spacing' => (is => 'lazy');
has 'scaled_width' => (is => 'lazy');
has 'scaled_spacing' => (is => 'lazy');
sub BUILD {
my $self = shift;
@ -55,4 +57,14 @@ sub _build_spacing {
return $self->width - &Slic3r::OVERLAP_FACTOR * ($self->width - $min_flow_spacing);
}
sub _build_scaled_width {
my $self = shift;
return scale $self->width;
}
sub _build_scaled_spacing {
my $self = shift;
return scale $self->spacing;
}
1;