From: Nick Ing-Simmons Date: Sat, 23 Nov 1996 19:54:52 +0000 (+0000) Subject: AutoLoader::AUTOLOAD optimization X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5a556d178903eb73ed2e240fee34fcfc607b2bb3;p=p5sagit%2Fp5-mst-13.2.git AutoLoader::AUTOLOAD optimization I notice that although *.al are right alongside autosplit.ix the trick AutoLoader::import uses to speed looking for the latter is not used to find the *.al files - anyone know why? On NFS mounted file systems at least, all the failed stats/opens are expensive. (Sadly I am testing this at home where everything is local...) p5p-msgid: <199611231954.TAA09921@ni-s.u-net.com> --- diff --git a/lib/AutoLoader.pm b/lib/AutoLoader.pm index fa9a322..be6429e 100644 --- a/lib/AutoLoader.pm +++ b/lib/AutoLoader.pm @@ -98,9 +98,22 @@ conflicts when used to split a module. =cut AUTOLOAD { - my $name = "auto/$AUTOLOAD.al"; - # Braces used on the s/// below to preserve $1 et al. - {$name =~ s#::#/#g} + my $name; + # Braces used to preserve $1 et al. + { + my ($pkg,$func) = $AUTOLOAD =~ /(.*)::([^:]+)$/; + $pkg =~ s#::#/#g; + if (defined($name=$INC{"$pkg.pm"})) + { + $name =~ s#^(.*)$pkg\.pm$#$1auto/$pkg/$func.al#; + $name = undef unless (-r $name); + } + unless (defined $name) + { + $name = "auto/$AUTOLOAD.al"; + $name =~ s#::#/#g; + } + } my $save = $@; eval {require $name}; if ($@) {