File::Temp takes quite a while to load - just less than 200ms, or 30-40%
of the time taken to |use Template| on my PIII-500. The attached patch
changes Template::Document to require File::Temp only when needed, meaning
that for compiled templates its never loaded at all.

(yes, I know I should be using mod_perl. Thats not an option ATM for
various reasons)

Thanks,

Bradley
Index: lib/Template/Document.pm
===================================================================
RCS file: /template-toolkit/Template2/lib/Template/Document.pm,v
retrieving revision 2.59
diff -u -r2.59 Document.pm
--- lib/Template/Document.pm    2002/08/15 16:41:21     2.59
+++ lib/Template/Document.pm    2002/10/15 09:33:10
@@ -33,7 +33,6 @@
 use base qw( Template::Base );
 use Template::Constants;
 #use Fcntl qw(O_WRONLY O_CREAT O_TRUNC);
-use File::Temp qw( tempfile );
 use File::Basename;
 
 $VERSION = sprintf("%d.%02d", q$Revision: 2.59 $ =~ /(\d+)\.(\d+)/);
@@ -278,7 +277,8 @@
        unless $file =~ /^(.+)$/s;
 
     eval {
-       ($fh, $tmpfile) = tempfile( DIR => dirname($file) );
+       require File::Temp;
+       ($fh, $tmpfile) = File::Temp::tempfile( DIR => dirname($file) );
        print $fh $class->as_perl($content) || die $!;
        close($fh);
     };
@@ -478,4 +478,4 @@
 
 =head1 SEE ALSO
 
-L<Template|Template>, L<Template::Parser|Template::Parser>
\ No newline at end of file
+L<Template|Template>, L<Template::Parser|Template::Parser>

Reply via email to