make Class->as_psgi_app only call ->new once
Matt S Trout [Thu, 7 Oct 2010 18:24:59 +0000 (19:24 +0100)]
lib/Web/Simple/Application.pm

index 3bdbd97..d52dc78 100644 (file)
@@ -260,8 +260,8 @@ sub _run_fcgi {
 }
 
 sub as_psgi_app {
-  my $self = shift;
-  ref($self) ? sub { $self->_dispatch(@_) } : sub { $self->new->_dispatch(@_) }
+  my $self = ref($_[0]) ? $_[0] : $_[0]->new;
+  sub { $self->_dispatch(@_) };
 }
 
 sub run {