diff options
author | Samuel Lebeau <samuel.lebeau@gmail.com> | 2010-08-03 11:25:15 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-08-03 11:52:19 +0200 |
commit | f01184ad9e7efbbcdb8581c93b92e16c61c7a6bd (patch) | |
tree | a348a6103b765f52373737e057400862e62c743e /actionpack | |
parent | e1142dfcae036bd8c6400962f9e07112b750b730 (diff) | |
download | rails-f01184ad9e7efbbcdb8581c93b92e16c61c7a6bd.tar.gz rails-f01184ad9e7efbbcdb8581c93b92e16c61c7a6bd.tar.bz2 rails-f01184ad9e7efbbcdb8581c93b92e16c61c7a6bd.zip |
Avoid potentially expensive inspect call in router. [#4491 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 77688fe397..d23b580d97 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -392,10 +392,9 @@ module ActionDispatch end def generate - error = ActionController::RoutingError.new("No route matches #{options.inspect}") path, params = @set.set.generate(:path_info, named_route, options, recall, opts) - raise error unless path + raise_routing_error unless path params.reject! {|k,v| !v } @@ -404,7 +403,7 @@ module ActionDispatch path << "?#{params.to_query}" if params.any? "#{script_name}#{path}" rescue Rack::Mount::RoutingError - raise error + raise_routing_error end def opts @@ -421,6 +420,10 @@ module ActionDispatch {:parameterize => parameterize} end + def raise_routing_error + raise ActionController::RoutingError.new("No route matches #{options.inspect}") + end + def different_controller? return false unless current_controller controller.to_param != current_controller.to_param |