diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index <HASH>..<HASH> 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1690,7 +1690,7 @@ module ActionDispatch
           end
 
           def shallow_nesting_depth #:nodoc:
-            @nesting.select(&:shallow?).size
+            @nesting.count(&:shallow?)
           end
 
           def param_constraint? #:nodoc:
A shorter and more concise version of select..size