[Catalyst-commits] r7516 -
Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Tue Mar 18 07:12:00 GMT 2008
Author: caelum
Date: 2008-03-18 07:12:00 +0000 (Tue, 18 Mar 2008)
New Revision: 7516
Modified:
Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/SmartURI.pm
Log:
Install autoloaded subs into the symbol table for a speed improvement.
Modified: Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/SmartURI.pm
===================================================================
--- Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/SmartURI.pm 2008-03-18 04:35:43 UTC (rev 7515)
+++ Catalyst-Plugin-SmartURI/1.000/trunk/lib/Catalyst/SmartURI.pm 2008-03-18 07:12:00 UTC (rev 7516)
@@ -81,23 +81,31 @@
sub AUTOLOAD {
use vars '$AUTOLOAD';
- my $self = shift;
+ no strict 'refs';
+ my $self = $_[0];
# stolen from URI sources
- my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::')+2);
+ my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::')+2);
return if ! blessed $self || $method eq 'DESTROY';
- my $class = $self->factory_class;
+ my $class = $self->factory_class;
- my @res;
- if (wantarray) {
- @res = $self->obj->$method($class->deflate_params(@_));
- } else {
- $res[0] = $self->obj->$method($class->deflate_params(@_));
- }
- @res = $class->inflate_params(@res);
+ my $sub = blessed($self)."::$method";
- return wantarray ? @res : $res[0];
+ *{$sub} = sub {
+ my $self = shift;
+ my @res;
+ if (wantarray) {
+ @res = $self->obj->$method($class->deflate_params(@_));
+ } else {
+ $res[0] = $self->obj->$method($class->deflate_params(@_));
+ }
+ @res = $class->inflate_params(@res);
+
+ return wantarray ? @res : $res[0];
+ };
+
+ goto &{$sub};
}
use overload
More information about the Catalyst-commits
mailing list