mirror of https://github.com/rails/rails
Use `args` instead of `*args` in `kwargs_request?` method
`*args` is not required here and should be avoided when not necessary because `*args` are slower than `args` and create unnecessary array allocations.
This commit is contained in:
parent
1e7640e68d
commit
e260975baf
|
@ -604,7 +604,7 @@ module ActionController
|
|||
def process(action, *args)
|
||||
check_required_ivars
|
||||
|
||||
if kwarg_request?(*args)
|
||||
if kwarg_request?(args)
|
||||
parameters, session, body, flash, http_method, format, xhr = args[0].values_at(:params, :session, :body, :flash, :method, :format, :xhr)
|
||||
else
|
||||
http_method, parameters, session, flash = args
|
||||
|
@ -745,7 +745,7 @@ module ActionController
|
|||
private
|
||||
|
||||
def process_with_kwargs(http_method, action, *args)
|
||||
if kwarg_request?(*args)
|
||||
if kwarg_request?(args)
|
||||
args.first.merge!(method: http_method)
|
||||
process(action, *args)
|
||||
else
|
||||
|
@ -757,7 +757,7 @@ module ActionController
|
|||
end
|
||||
|
||||
REQUEST_KWARGS = %i(params session flash method body xhr)
|
||||
def kwarg_request?(*args)
|
||||
def kwarg_request?(args)
|
||||
args[0].respond_to?(:keys) && (
|
||||
(args[0].key?(:format) && args[0].keys.size == 1) ||
|
||||
args[0].keys.any? { |k| REQUEST_KWARGS.include?(k) }
|
||||
|
|
|
@ -81,7 +81,7 @@ module ActionDispatch
|
|||
#
|
||||
# xhr :get, '/feed', params: { since: 201501011400 }
|
||||
def xml_http_request(request_method, path, *args)
|
||||
if kwarg_request?(*args)
|
||||
if kwarg_request?(args)
|
||||
params, headers, env = args.first.values_at(:params, :headers, :env)
|
||||
else
|
||||
params = args[0]
|
||||
|
@ -291,7 +291,7 @@ module ActionDispatch
|
|||
end
|
||||
|
||||
def process_with_kwargs(http_method, path, *args)
|
||||
if kwarg_request?(*args)
|
||||
if kwarg_request?(args)
|
||||
process(http_method, path, *args)
|
||||
else
|
||||
non_kwarg_request_warning if args.present?
|
||||
|
@ -300,7 +300,7 @@ module ActionDispatch
|
|||
end
|
||||
|
||||
REQUEST_KWARGS = %i(params headers env xhr)
|
||||
def kwarg_request?(*args)
|
||||
def kwarg_request?(args)
|
||||
args[0].respond_to?(:keys) && args[0].keys.any? { |k| REQUEST_KWARGS.include?(k) }
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue