Subject: | Optimization for D::P::DataFu::Grid |
Date: | Fri, 14 Oct 2011 17:09:26 -0700 |
To: | bug-Dancer-Plugin-DataFu [...] rt.cpan.org |
From: | David Seleno <dave [...] seleno.net> |
in sub render, move the Template object creation out of the inner subroutine to increase performance.
This way you only create one Template object per call to render, rather than one for every sub-component and cell of the rendered grid.
For most grid renders I saw my execution times decrease by 50-90%.
my $template = Template->new(
INTERPOLATE => 1,
EVAL_PERL => 1,
ABSOLUTE => 1,
ANYCASE => 1
);
my $tempro = sub {
my ($file, $args) = @_;
# moved Template->new out
my $data = undef;
$template->process( $file, $args, \$data ) || die $template->error;
return $data;
};