Permalink
Browse files

Avoid potentially expensive inspect call in router. [#4491 state:reso…

…lved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 503931d commit a44779e9bb2b4af0ce6d0e77746e751c9b10d823 @samleb samleb committed with josevalim Aug 3, 2010
Showing with 6 additions and 3 deletions.
  1. +6 −3 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -392,10 +392,9 @@ def handle_nil_action!
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 @@ def generate
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 @@ def opts
{: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

0 comments on commit a44779e

Please sign in to comment.