Skip Menu |

This queue is for tickets about the Class-Autouse CPAN distribution.

Report information
The Basics
Id: 13468
Status: resolved
Worked: 35 min
Priority: 0/
Queue: Class-Autouse

People
Owner: adamk [...] cpan.org
Requestors: Marek.Rouchal [...] gmx.net
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.17
Fixed in: (no value)



Subject: disable file existence check in autouse
We have a lot of Perl classes in out environment, which are loaded via NFS. While the file existence check Class::Autouse does is useful during development to catch wrong class names, it significantly prolongs the startup time of scripts because of the stat() done. The proposed patch below introduces a global variable to disable this check. The default is to keep it on. It works better if instead of "use vars" one would use "our" to be able to pre-declare $Class::Autouse::CHECK before "use Class::Autouse", but for us that is not a big issue. Keep up the good work! -Marek --- lib/Class/Autouse.pm.orig 2005-06-29 15:25:29.332781000 +0200 +++ lib/Class/Autouse.pm 2005-06-29 15:31:43.207882000 +0200 @@ -19,7 +19,7 @@ use List::Util (); # Globals -use vars qw{$VERSION $DEBUG $DEVEL $SUPERLOAD}; # Load environment +use vars qw{$VERSION $DEBUG $DEVEL $SUPERLOAD $CHECK}; # Load environment use vars qw{$HOOKS %chased %loaded %special %bad}; # Working data use vars qw{*_UNIVERSAL_can}; # Subroutine storage BEGIN { @@ -35,6 +35,9 @@ # We always start with the superloader off $SUPERLOAD = 0; + # we want to check for existence of files, unless disabled + $CHECK = 1 unless(defined $CHECK); + # AUTOLOAD hook counter $HOOKS = 0; @@ -138,7 +141,7 @@ # Does the file for the class exist? my $file = _class_file($class); next if exists $INC{$file}; - unless ( _file_exists($file) ) { + if ( $CHECK && !_file_exists($file) ) { my $inc = join ', ', @INC; _cry "Can't locate $file in \@INC (\@INC contains: $inc)"; } @@ -350,7 +353,7 @@ return $loaded{$class} = 1 if $INC{$file} ne 'Class::Autouse'; # Because we autoused it earlier, we know the file for this - # class MUST exist. + # class MUST exist (or the check was explicitely disabled). # Removing the AUTOLOAD hook and %INC lock is all we have to do delete ${"${class}::"}{'AUTOLOAD'}; delete $INC{$file};
WILLFIX Haven't got time to patch and check right now (or rather to write the POD), but should get to it shortly. Will probably rename to something more specific than "CHECK". Would something like $CHECKFILES or $NOSTAT (default to false) sound right to you?