[Jifty-commit] r6604 - in jifty/trunk: lib/Jifty

Jifty commits jifty-commit at lists.jifty.org
Tue Mar 17 10:57:21 EDT 2009


Author: alexmv
Date: Tue Mar 17 10:57:19 2009
New Revision: 6604

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Dispatcher.pm

Log:
 r43243 at kohr-ah:  chmrr | 2009-03-17 10:19:08 -0400
 Having a local $Request saves thousands of method calls to Class::Accessor per request


Modified: jifty/trunk/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Dispatcher.pm	(original)
+++ jifty/trunk/lib/Jifty/Dispatcher.pm	Tue Mar 17 10:57:19 2009
@@ -286,8 +286,9 @@
 >;
 
 our $Dispatcher;
+our $Request;
 
-sub request       { Jifty->web->request }
+sub request       { $Request }
 sub _ret (@);
 sub under ($$@)   { _ret @_ }    # partial match at beginning of path component
 sub before ($$@)  { _ret @_ }    # exact match on the path component
@@ -304,9 +305,9 @@
 sub set ($$@)     { _ret @_ }    # set parameter
 sub del ($@)      { _ret @_ }    # remove parameter
 sub get ($) {
-    my $val = request->template_argument( $_[0] );
+    my $val = $Request->template_argument( $_[0] );
     return $val if defined $val;
-    return request->argument( $_[0] );
+    return $Request->argument( $_[0] );
 }
 
 sub _qualify ($@);
@@ -483,9 +484,10 @@
     # do it once per request. But it's really, really painful when you
     # do it often, as is the case with fragments
     local $SIG{__DIE__} = 'DEFAULT';
+    local $Request = Jifty->web->request;
 
     eval {
-        my $path = Jifty->web->request->path;
+        my $path = $Request->path;
         utf8::downgrade($path); # Mason handle non utf8 path.
         $Dispatcher->_do_dispatch( $path );
     };
@@ -808,21 +810,21 @@
     my ( $self, $key, $value ) = @_;
     no warnings 'uninitialized';
     $self->log->debug("Setting argument $key to $value");
-    request->template_argument($key, $value);
+    $Request->template_argument($key, $value);
 }
 
 sub _do_del {
     my ( $self, $key ) = @_;
     $self->log->debug("Deleting argument $key");
-    request->delete($key);
+    $Request->delete($key);
 }
 
 sub _do_default {
     my ( $self, $key, $value ) = @_;
     no warnings 'uninitialized';
     $self->log->debug("Setting argument default $key to $value");
-    request->template_argument($key, $value)
-        unless defined request->argument($key) or defined request->template_argument($key);
+    $Request->template_argument($key, $value)
+        unless defined $Request->argument($key) or defined $Request->template_argument($key);
 }
 
 =head2 _do_dispatch [PATH]
@@ -919,9 +921,8 @@
     elsif ( ref($cond) eq 'HASH' ) {
         local $@;
         my $rv = eval {
-            for my $key ( sort keys %$cond )
+            for my $key ( sort grep {length} keys %$cond )
             {
-                next if $key eq '';
                 my $meth = "_match_$key";
                 $self->$meth( $cond->{$key} ) or return;
             }
@@ -957,7 +958,7 @@
 sub _match_method {
     my ( $self, $method ) = @_;
     #$self->log->debug("Matching method ".request->request_method." against ".$method);
-    lc( request->request_method ) eq lc($method);
+    $Request->request_method eq uc($method);
 }
 
 =head2 _match_https


More information about the Jifty-commit mailing list