mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Avoid potentially expensive inspect call in router. [#4491 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
committed by
José Valim
parent
503931df05
commit
a44779e9bb
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user