diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-11-24 08:48:01 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-11-24 09:19:21 -0200 |
commit | ccdf54d6fcc96e70a2049f9828241037156067d8 (patch) | |
tree | 262e4fd6034993f70cb97a2f78de61e68c2bdc7d /actionpack | |
parent | d98014cbcb0bf38f4ecd433d945047fc67fccc36 (diff) | |
download | rails-ccdf54d6fcc96e70a2049f9828241037156067d8.tar.gz rails-ccdf54d6fcc96e70a2049f9828241037156067d8.tar.bz2 rails-ccdf54d6fcc96e70a2049f9828241037156067d8.zip |
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.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index ac078174ed..0c19b493ab 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -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 |