From 69187e640a8c92c899944a5ce15301b9f27645f4 Mon Sep 17 00:00:00 2001 From: hjp Date: Mon, 5 Mar 2007 18:13:54 +0000 Subject: [PATCH] Speedup by by 63 % (from 85 ms to 52 ms on a 3 GHz P4) for a typical usecase (prepend single directory to PATH with 12 directories with checking) by loading Pod::Usage only if necessary. This script is called quite frequently in my .zshrc, so performance is important (maybe I should rewrite it in C?) --- pathtools/preppath.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pathtools/preppath.pl b/pathtools/preppath.pl index 38fb2a7..4884fc5 100755 --- a/pathtools/preppath.pl +++ b/pathtools/preppath.pl @@ -38,7 +38,6 @@ Peter J. Holzer . use strict; use Getopt::Long; -use Pod::Usage; my $check; my $debug; @@ -46,7 +45,11 @@ my $var = 'PATH'; GetOptions("check" => \$check, "debug" => \$debug, "var=s" => \$var, - ) or pod2usage(2); + ) or do { + require Pod::Usage; + import Pod::Usage; + pod2usage(2); + }; my $path = $ENV{$var} || ''; my @path = split(/:/, $path);