From 919e7d3e6cfff09c9da34c09b8938c34f653c477 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <aaron.patterson@gmail.com>
Date: Sun, 9 Aug 2015 17:11:33 -0700
Subject: push `scope` calls up one frame

eliminates calling `scope` in one method, pushes the other calls up one
frame.  This goes a little way towards eliminating the internal calls to
`scope`.
---
 actionpack/lib/action_dispatch/routing/mapper.rb | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

(limited to 'actionpack')

diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 1264e7e00b..e047d57ac7 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1421,7 +1421,9 @@ module ActionDispatch
 
           with_scope_level(:member) do
             if shallow?
-              shallow_scope(parent_resource.member_scope) { yield }
+              shallow_scope {
+                path_scope(parent_resource.member_scope) { yield }
+              }
             else
               path_scope(parent_resource.member_scope) { yield }
             end
@@ -1447,9 +1449,15 @@ module ActionDispatch
 
           with_scope_level(:nested) do
             if shallow? && shallow_nesting_depth >= 1
-              shallow_scope(parent_resource.nested_scope, nested_options) { yield }
+              shallow_scope do
+                path_scope(parent_resource.nested_scope) do
+                  scope(nested_options) { yield }
+                end
+              end
             else
-              scope(parent_resource.nested_scope, nested_options) { yield }
+              path_scope(parent_resource.nested_scope) do
+                scope(nested_options) { yield }
+              end
             end
           end
         end
@@ -1720,12 +1728,12 @@ module ActionDispatch
             resource_method_scope? && CANONICAL_ACTIONS.include?(action.to_s)
           end
 
-          def shallow_scope(path, options = {}) #:nodoc:
+          def shallow_scope #:nodoc:
             scope = { :as   => @scope[:shallow_prefix],
                       :path => @scope[:shallow_path] }
             @scope = @scope.new scope
 
-            scope(path, options) { yield }
+            yield
           ensure
             @scope = @scope.parent
           end
-- 
cgit v1.2.3