From 5a556d178903eb73ed2e240fee34fcfc607b2bb3 Mon Sep 17 00:00:00 2001 From: Nick Ing-Simmons Date: Sat, 23 Nov 1996 19:54:52 +0000 Subject: [PATCH] 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> --- lib/AutoLoader.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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 ($@) { -- 2.7.4