From a293812bffbc6e634e1a6e6794e9dec537d522a3 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 14 Aug 2015 18:04:49 -0700 Subject: only keep one hash of named routes The outer router object already keeps a hash of named routes, so we should just use that. --- actionpack/lib/action_dispatch/journey/formatter.rb | 2 +- actionpack/lib/action_dispatch/journey/routes.rb | 5 +---- actionpack/lib/action_dispatch/routing/route_set.rb | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/journey/formatter.rb b/actionpack/lib/action_dispatch/journey/formatter.rb index d8bb10ffab..c19ff0f4db 100644 --- a/actionpack/lib/action_dispatch/journey/formatter.rb +++ b/actionpack/lib/action_dispatch/journey/formatter.rb @@ -155,7 +155,7 @@ module ActionDispatch def build_cache root = { ___routes: [] } - routes.each_with_index do |route, i| + routes.routes.each_with_index do |route, i| leaf = route.required_defaults.inject(root) do |h, tuple| h[tuple] ||= {} end diff --git a/actionpack/lib/action_dispatch/journey/routes.rb b/actionpack/lib/action_dispatch/journey/routes.rb index dacb0ccf48..4770b8b7cc 100644 --- a/actionpack/lib/action_dispatch/journey/routes.rb +++ b/actionpack/lib/action_dispatch/journey/routes.rb @@ -5,11 +5,10 @@ module ActionDispatch class Routes # :nodoc: include Enumerable - attr_reader :routes, :named_routes, :custom_routes, :anchored_routes + attr_reader :routes, :custom_routes, :anchored_routes def initialize @routes = [] - @named_routes = {} @ast = nil @anchored_routes = [] @custom_routes = [] @@ -37,7 +36,6 @@ module ActionDispatch routes.clear anchored_routes.clear custom_routes.clear - named_routes.clear end def partition_route(route) @@ -72,7 +70,6 @@ module ActionDispatch route.precedence = routes.length routes << route - named_routes[name] = route if name && !named_routes[name] partition_route(route) clear_cache! route diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 4f698c84ab..30e308119d 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -143,6 +143,7 @@ module ActionDispatch end def key?(name) + return unless name routes.key? name.to_sym end @@ -356,7 +357,7 @@ module ActionDispatch @set = Journey::Routes.new @router = Journey::Router.new @set - @formatter = Journey::Formatter.new @set + @formatter = Journey::Formatter.new self @dispatcher_class = Routing::RouteSet::Dispatcher end -- cgit v1.2.3