From: Aristotle Pagaltzis Date: Thu, 17 Dec 2009 15:47:24 +0000 (+0100) Subject: simplify (and speed up) `_get_allowed_methods` X-Git-Tag: 0.80~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-REST.git;a=commitdiff_plain;h=846b6b07ee0358296e8bb5b636dc0c095cb063a3 simplify (and speed up) `_get_allowed_methods` --- diff --git a/lib/Catalyst/Action/REST.pm b/lib/Catalyst/Action/REST.pm index 27705fc..68ed90a 100644 --- a/lib/Catalyst/Action/REST.pm +++ b/lib/Catalyst/Action/REST.pm @@ -125,14 +125,8 @@ sub dispatch { sub _get_allowed_methods { my ( $self, $controller, $c, $name ) = @_; my $class = ref($controller) ? ref($controller) : $controller; - my $methods = Class::Inspector->methods($class); - my @allowed; - foreach my $method ( @{$methods} ) { - if ( $method =~ /^$name\_(.+)$/ ) { - push( @allowed, $1 ); - } - } - return @allowed; + my $methods = Class::Inspector->methods($class); + return map { /^$name\_(.+)$/ } @$methods; }; sub _return_options {