CC: | perl5-porters [...] perl.org, bug-AutoLoader [...] rt.cpan.org |
Subject: | Re: AutoLoader slowness in "can" |
Date: | Thu, 29 Nov 2007 14:05:46 +0100 |
To: | Graham Barr <gbarr [...] pobox.com> |
From: | Steffen Mueller <l2ot9pa02 [...] sneakemail.com> |
Hi Graham, hi p5p,
Graham Barr wrote:
Show quoted text
> I do not see the point of AutoLoader::can
>
> A module that uses the AutoLoader package should be installed using the
> AutoSplit package. The result will be that sub stubs will be created for
> every method/sub that is to be AUTOLOADed. This will cause the default
> ->can method in UNIVERSAL to return a reference to the sub stub. When
> the method is called it will get loaded.
>
> AutoLoader::can does call SUPER::can first and return if that is true,
> so the code in AutoLoader::can will only ever do its checking if the
> package that is using AutoLoader was not installed correctly with
> AutoSplit or the method being requested does not exist.
>
Along with all tests that assume AutoLoader::can works without a sub stub?
Just to make sure: Do I understand you correctly in that you are saying
AutoLoader should not try to work if there are no sub stubs in the user
code (generated by AutoSplit or by hand)?
I would assume that this breaks quite some code, no?
Best regards,
Steffen
>> The root of the problem is that the "require" in AutoLoader::can is
>> called every time. A possible fix is to fake %INC so that require is
>> called only once. See the attached patch.
>
> IMO, AutoLoader::can should just be removed all together.