mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Refector a bit to remove extra slice iteration and splat call
This yields a small bit of performance improvement when building the defaults from constraints, specially considering that it's rather common for constraints to be empty. Also, there's a bit of duplicated code in here that I have to check before extracting.
This commit is contained in:
parent
d98014cbcb
commit
ccdf54d6fc
1 changed files with 2 additions and 2 deletions
|
@ -252,7 +252,7 @@ module ActionDispatch
|
|||
|
||||
def defaults_from_constraints(constraints)
|
||||
url_keys = [:protocol, :subdomain, :domain, :host, :port]
|
||||
constraints.slice(*url_keys).select{ |k, v| v.is_a?(String) || v.is_a?(Fixnum) }
|
||||
constraints.select { |k, v| url_keys.include?(k) && (v.is_a?(String) || v.is_a?(Fixnum)) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -858,7 +858,7 @@ module ActionDispatch
|
|||
|
||||
def defaults_from_constraints(constraints)
|
||||
url_keys = [:protocol, :subdomain, :domain, :host, :port]
|
||||
constraints.slice(*url_keys).select{ |k, v| v.is_a?(String) || v.is_a?(Fixnum) }
|
||||
constraints.select { |k, v| url_keys.include?(k) && (v.is_a?(String) || v.is_a?(Fixnum)) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue